This is a react library that creates an epub structure. This library only provides the file structure. To get a valid epub file it is needed to to create files from the provided data and compress them to a epub file.
npm install @cd-z/epub-constructorThis is a typescript library that create an epub structor. This library dose not save the structored epub file, you have to do that your self.
This library work for react, react-native and web.
It simple create a structored epub object that you could save it to your desired location later on.
npm install @cd-z/epub-constructor
`` this is chapter 1 this is chapter 1js`
import EpubFile from 'epub-constructor'
var epub = new EpubFile({
title: "example",
fileName: "examplefile" // optional, it will take title if not set
language: "en",
description: "this is a epub test",
stylesheet:{
p: {
width:"100%"
}
},
chapters:[{
fileName: "examplefile" // optional, it will take title if not set
title: "Air born",
htmlBody: "
},{
title:"chapter 2",
htmlBody: "
}]
});
var file = await epub.constructEpub();
// save the file to your device
This is what file will containe
` this is a content this is a contentjs`
[
{path:"mimetype",content:"application/epub+zip"},
{path:"META-INF/container.xml",content:"
{path:"EPUB/styles.css",content:'body { font-family: "Helvetica Neue", "Helvetica", "Arial", sans-serif; font-size: 1.125em; line-height: 1.6em; color: #000; } h1, h2, h3, h4, h5, h6 { line-height: 1em; } h1 { font-size: 3em; } h2 { font-size: 2.5em; } p { width: 100%; }'},
{path:"EPUB/Air born.html",content:'
{path:"EPUB/chapter 2.html",content:'
{path:"EPUB/example.opf",content:'
{path:"EPUB/toc.html",content:'
{path:"EPUB/toc.ncx",content:'
]
You will have to create those files and make a zip file there after.
You could also read an epub file and begin to modify or append chapters there after.
` this is chapter 3js``
// file have to be extracted by your self. It should look like the above json and be created by this library
var settings = EpubFile.load(file);
settings.chapters.push({
title: 'chapter 3',
htmlBody: '
});
var epub = new EpubFile(settings);
var file = await epub.constructEpub();
// save the file to your device
This library is new and it may containe some bugs so please report those.
Will be glad if someone is able to create an android and IOS modules that can create the actual epub(zip) file