Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take Epup file from local #319

Open
5 tasks done
aliMurtaja opened this issue Oct 21, 2024 · 3 comments
Open
5 tasks done

Take Epup file from local #319

aliMurtaja opened this issue Oct 21, 2024 · 3 comments

Comments

@aliMurtaja
Copy link

aliMurtaja commented Oct 21, 2024

Summary

Hello,

Honestly such a great package, I came across docs, need to pass src as a http.

<Reader
src="https://github.com/IDPF/epub3-samples/releases/download/20230704/accessible_epub_3.epub"
width={width}
height={height}
fileSystem={useFileSystem}
waitForLocationsReady
/ >

Is there any way to pass local file reference, I mean first Epub will download into app, and then we could somehow use downloaded file, So that not restriction for internet

What platform(s) does this occur on?

Android, iOS

What workflow(s) does this occur on?

Bare Workflow

Environment (or package.json)

Local Enviroment

Your .epub file

No response

Minimal reproducible example

No response

I confirm that i have

  • I looked for a solution to my problem in other open and resolved issues
  • I checked the examples provided solve my problem
  • I have verified that my problem is not caused by a third-party library
  • I cloned the project environment examples and still the problem persists
  • I'm using the latest available version of the library and its complements
@aliMurtaja
Copy link
Author

image

Asking file password

@aliMurtaja
Copy link
Author

aliMurtaja commented Oct 21, 2024

It working now, needed to add data:application/oebps-package+xml;base64, prefix

But application is very slow, when I swipes to next page, it takes around 2min to navigate, is there any solution ?

This is my code

import React, {useEffect, useState} from 'react';

import { SafeAreaView, Text, Button } from 'react-native';
import { Reader, useReader } from '@epubjs-react-native/core';
import { useFileSystem } from '@epubjs-react-native/file-system'; // for Bare React Native project
import { Annotations } from './Annotation';
import { Bookmarks } from './Bookmarks';
import { BookmarksList } from './Bookmarks/BookmarksList';
import Toc from './TableOfContents';
// import { useFileSystem } from '@epubjs-react-native/expo-file-system'; // for Expo project
import ExampleE from './../../src/components/baseSF/base64'
import { Formats } from './Formates';
var RNFS = require('react-native-fs');

export default function Epub() {
const [basesf, setBasesf] = useState(null);
function onPressLearnMore() {
RNFS.readFile(RNFS.ExternalStorageDirectoryPath+ "/clinic/another.txt").then((res)=>{
setBasesf(res)
}).catch(err=> console.log(err))
}

useEffect(()=>{
console.log('FILE WRITTEN! 2', basesf)
}, [basesf])

if(!basesf){
return <Button
// onPress={()=>onPressLearnMore_(RNFS.ExternalStorageDirectoryPath+ "/clinic/example.epub")}
onPress={onPressLearnMore}
title="Learn More"
color="#841584"
accessibilityLabel="Learn more about this purple button"
/>
}

return (
<SafeAreaView style={{ flex: 1 }}>
<Reader
src = {"data:application/oebps-package+xml;base64,"+basesf}
fileSystem={useFileSystem}
width={"100%"}
height={700}
/>

);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@aliMurtaja and others