You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that when you access book.spineItems[n].contents, or something like that it's only available after the book has been rendered.
Is there a way to access the epub text without rendering the document first?
Currently I use this to get all text in a given book:
// Initialize the book with the path to the .epub file
var book = ePub("myEpub.epub");
// Array to store the text contents of each section
var sectionsContents = [];
// Render the book
var rendition = book.renderTo("area", { flow: "scrolled-doc", width: 600, height: 400 });
// Handle rendering events
rendition.display().then(async function() {
var spineItems = rendition.book.spine.spineItems;
console.log(spineItems.length)
for(var i =0; i< spineItems.length; i++){
spineItem = spineItems[i];
sectionsContents.push(spineItem.contents.innerText);
await rendition.next()
}
});
This works, but seems a bit clunky.
The text was updated successfully, but these errors were encountered:
I noticed that when you access book.spineItems[n].contents, or something like that it's only available after the book has been rendered.
Is there a way to access the epub text without rendering the document first?
Currently I use this to get all text in a given book:
This works, but seems a bit clunky.
The text was updated successfully, but these errors were encountered: