scerio / epubx.dart Goto Github PK
View Code? Open in Web Editor NEWThis project forked from orthros/dart-epub
Epub Reader and Writer for Dart
License: MIT License
This project forked from orthros/dart-epub
Epub Reader and Writer for Dart
License: MIT License
Can you provide an example of creating epub from scratch?
I would like to generate epub from String content (web scraping or RSS).
But the only example seems to be an epub reader.
My code seems to stop at this line
List bytes = await targetFile.readAsBytes();
I have a print after but it doesnt show, any ideas why ?
Hi, first of all, nice work. However, I have been working with the package and I load an epub file (there are more with the same problem, this one is to view the problem), and the HtmlContent of some or all chapters get me a body with an empty div.
However, the content of each file is well parsed by the package with all the content, so there are a problem with the chapters, the list is no complete or is missing some notes or the whole content except the title.
I also used the epub_view package to verify the issue and the same happend, some chapters are missing by bad parsing of those.
This is different from #3. I have tested the file they linked and it does not throw an exception.
Describe the bug
The method ChapterReader.getChaptersImpl is throwing an exception because it can't find the key in the html map
I have identified the cause in ChapterReader.getChaptersImpl (line 34)
if (!bookRef.Content!.Html!.containsKey(contentFileName))
Where:
contentFileName
is "../Text/Section00001.xhtml"
but the actual key in bookRef.Content!.Html!
is "Text/Section00001.xhtml"
So it throws the exception
To Reproduce
Steps to reproduce the behavior:
In version 4.0.0 (and I think earlier as the same), some pages are missing.
Try with Sway.epub. I am comparing the view of epubx (with epub_view) and "book" (pre-installed on macosx). In epubx, Sway_copyright.html
, Sway_toc.html
, Sway_body_split_000.html
and Sway_body_split_000.html
are not showing up.
This seems to be because the .chapters
are made from NCX, so items that are in Spine and not in NCX are missing.
In Spine, all xhtml files are defined.
<spine toc="ncx">
<itemref idref="ut8KdiaIv9Ka6BnbBwmGtD5"/> <!-- OEBPS/cover.xml -->
<itemref idref="copyright"/> <!-- OEBPS/Sway_copyright.html -->
<itemref idref="toc"/> <!-- OEBPS/Sway_toc.html -->
<itemref idref="book5"/> <!-- OEBPS/Sway_body_split_000.html -->
<itemref idref="book4"/> <!-- OEBPS/Sway_body_split_001.html -->
<itemref idref="book3"/> <!-- OEBPS/Sway_body_split_002.html -->
<itemref idref="book2"/> <!-- OEBPS/Sway_body_split_003.html -->
<itemref idref="book1"/> <!-- OEBPS/Sway_body_split_004.html -->
</spine>
However, in toc.ncx
, only 3 navPoints are defined.
<navMap>
<navPoint class="titlepage" id="level1-titlepage" playOrder="1">
<navLabel>
<text>AUTHOR'S NOTE</text>
</navLabel>
<content src="OEBPS/Sway_body_split_002.html"/>
</navPoint>
<navPoint class="book" id="level1-book1" playOrder="2">
<navLabel>
<text>PART ONE</text>
</navLabel>
<content src="OEBPS/Sway_body_split_003.html"/>
<navPoint class="chapter" id="level2-book1chap01" playOrder="3">
<navLabel>
<text>THE HOUSES, 1969</text>
</navLabel>
<content src="OEBPS/Sway_body_split_004.html"/>
</navPoint>
</navPoint>
</navMap>
Currently, I believe that getting contents from chapters
is dangerous due to the possibility of missing pages. Is there any solution to this problem?
Describe the bug
As reported in the original pre-fork version, After EpubReader.readBook loads an epub, most epubs fail to return anything from (loadedBook).CoverImage
To Reproduce
loadedBook = (await rootBundle.load(bookPath)).buffer.asUint8List();
works fine
currentBook = EpubReader.readBook(loadedBook);
works fine
bookCoverImage= currentBook.CoverImage;
Always seems to return null
Expected behaviour
A returned image object containing data
Additional context
See Issues section of original package that this is a fork of.
xml:lang
, and dir
attributes.final epubx.EpubMetadataTitle primaryTitle = (titles.firstWhereOrNull(
(epubx.EpubMetadataTitle? titleElement) {
final epubx.EpubMetadataMeta? associatedMeta = _getMetaAssociatedWithTitle(
metaItems: epubMetadata.MetaItems,
titleElement: titleElement,
);
if (associatedMeta != null && associatedMeta.Scheme == null) {
return (associatedMeta.Content == 'main');
}
return false;
},
) ??
titles.first);
final epubx.EpubMetadataTitle? subtitle = titles.firstWhereOrNull(
(epubx.EpubMetadataTitle? titleElement) {
final epubx.EpubMetadataMeta? associatedMeta = _getMetaAssociatedWithTitle(
metaItems: epubMetadata.MetaItems,
titleElement: titleElement,
);
if (associatedMeta != null && associatedMeta.Scheme == null) {
return (associatedMeta.Content == 'subtitle');
}
return false;
},
);
static epubx.EpubMetadataMeta? _getMetaAssociatedWithTitle({
required List<epubx.EpubMetadataMeta>? metaItems,
required epubx.EpubMetadataTitle? titleElement,
}) {
return metaItems?.firstWhereOrNull(
(meta) => (meta.Refines == '#${titleElement?.Id}' && (meta.Property == 'title-type')),
);
}
The data coming from the package can be transferred to classes and stored as it is in a database that accepts this matter.
I do not like to use Pull Requests permanently.
Could you expose all the opf schema's? Currently, only a limited amount is exported and thus can be referenced in code.
For example: you export epub_metadata_creator.dart but not epub_metadata_identifier.dart
Is this on purpose? Looking forward to your reply.
The Plugin needs update because it depends on an old version of flutter that conflicts with another packages, thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.