File tree 4 files changed +15
-7
lines changed
4 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import MyViewer from './components/Viewer';
6
6
export default function App ( ) {
7
7
return (
8
8
< View style = { styles . container } >
9
- < MyViewer />
9
+ < MyViewer document = { "https://pdftron.s3.amazonaws.com/downloads/pl/PDFTRON_about.pdf" } />
10
10
</ View >
11
11
) ;
12
12
}
Original file line number Diff line number Diff line change 1
- # pdftron-react- and-react-native-sample
2
- This sample project uses Expo and shows how to create a PDF viewer app with shared code between React and React Native.
1
+ # PDFTron React and React Native PDF Viewer Sample
2
+ This sample project uses Expo and shows how to create a PDF viewer app for both web and mobile with a single codebase between React and React Native.
3
3
4
4
## Install
5
5
Original file line number Diff line number Diff line change @@ -3,15 +3,19 @@ import {useEffect} from 'react';
3
3
4
4
import { DocumentView , RNPdftron } from 'react-native-pdftron' ;
5
5
6
- const MyComponent = ( ) => {
6
+ type ViewerProps = {
7
+ document : string
8
+ }
9
+
10
+ const MyComponent = ( { document } : ViewerProps ) => {
7
11
8
12
useEffect ( ( ) => {
9
13
RNPdftron . initialize ( "Insert commercial license key here after purchase" ) ;
10
14
} , [ ] ) ;
11
15
12
16
return (
13
17
< DocumentView
14
- document = { "https://pdftron.s3.amazonaws.com/downloads/pl/PDFTRON_about.pdf" }
18
+ document = { document }
15
19
padStatusBar
16
20
/>
17
21
) ;
Original file line number Diff line number Diff line change @@ -2,14 +2,18 @@ import React from 'react';
2
2
import { useEffect , useRef } from 'react' ;
3
3
import WebViewer from '@pdftron/webviewer' ;
4
4
5
- const MyComponent = ( ) => {
5
+ type ViewerProps = {
6
+ document : string
7
+ }
8
+
9
+ const MyComponent = ( { document } : ViewerProps ) => {
6
10
const viewer = useRef < HTMLDivElement > ( null ) ;
7
11
8
12
useEffect ( ( ) => {
9
13
WebViewer (
10
14
{
11
15
path : 'lib' ,
12
- initialDoc : 'https://pdftron.s3.amazonaws.com/downloads/pl/PDFTRON_about.pdf' ,
16
+ initialDoc : document ,
13
17
} ,
14
18
viewer . current as HTMLDivElement ,
15
19
) . then ( ( instance ) => {
You can’t perform that action at this time.
0 commit comments