npm i --save nativescript-epub-reader
- Version: 1.0.0
- GitHub:
- NPM: https://www.npmjs.com/package/nativescript-epub-reader
- Downloads:
- Last Day: 0
- Last Week: 0
- Last Month: 0
nativescript-epub-reader
NativeScript plugin to open and read ePub files natively.
Getting Started
npm install nativescript-epub-reader
- For iOS Place your
epub
files in yourApp_Resources/iOS
directory. - For Android, required absolute file path as parameter.
- Import
EpubReader
in your page and open the file.
Android Permissions Required
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
AndroidManifest
Starting with Android 9.0 (API level 28), cleartext support is disabled by default.
{your-app-module}/res/xml/network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">127.0.0.1</domain>
<domain includeSubdomains="true">localhost</domain>
</domain-config>
</network-security-config>
Then add network_security_config.xml in your app module's AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
...
<application android:networkSecurityConfig="@xml/network_security_config">
...
</application>
</manifest>
Code Sample
import {Observable} from 'data/observable';
import { EpubReader } from 'nativescript-epub-reader';
import * as application from "tns-core-modules/application";
export class HelloWorldModel extends Observable {
constructor() {
super();
let ePubReader = new EpubReader();
if (application.android) {
ePubReader.open('/storage/emulated/0/Download/Metamorphosis-jackson.epub');
}else{
ePubReader.open('book');
}
}
}
IOS Demo
Android Demo
Custom Fonts
Day and Night Mode
Text Highlighting
Media Overlays
Credits
- https://github.com/FolioReader/FolioReaderKit
- https://github.com/FolioReader/FolioReader-Android
License
Apache License Version 2.0, January 2004