Skip to content

Commit c3b868f

Browse files
committed
move document path out
1 parent 0f88658 commit c3b868f

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

App.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import MyViewer from './components/Viewer';
66
export default function App() {
77
return (
88
<View style={styles.container}>
9-
<MyViewer />
9+
<MyViewer document={"https://pdftron.s3.amazonaws.com/downloads/pl/PDFTRON_about.pdf"}/>
1010
</View>
1111
);
1212
}

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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.
33

44
## Install
55

components/Viewer/Viewer.native.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@ import {useEffect} from 'react';
33

44
import { DocumentView, RNPdftron } from 'react-native-pdftron';
55

6-
const MyComponent = () => {
6+
type ViewerProps = {
7+
document: string
8+
}
9+
10+
const MyComponent = ({ document }: ViewerProps) => {
711

812
useEffect(() => {
913
RNPdftron.initialize("Insert commercial license key here after purchase");
1014
}, []);
1115

1216
return (
1317
<DocumentView
14-
document={"https://pdftron.s3.amazonaws.com/downloads/pl/PDFTRON_about.pdf"}
18+
document={document}
1519
padStatusBar
1620
/>
1721
);

components/Viewer/Viewer.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@ import React from 'react';
22
import {useEffect, useRef} from 'react';
33
import WebViewer from '@pdftron/webviewer';
44

5-
const MyComponent = () => {
5+
type ViewerProps = {
6+
document: string
7+
}
8+
9+
const MyComponent = ({ document }: ViewerProps) => {
610
const viewer = useRef<HTMLDivElement>(null);
711

812
useEffect(() => {
913
WebViewer(
1014
{
1115
path: 'lib',
12-
initialDoc: 'https://pdftron.s3.amazonaws.com/downloads/pl/PDFTRON_about.pdf',
16+
initialDoc: document,
1317
},
1418
viewer.current as HTMLDivElement,
1519
).then((instance) => {

0 commit comments

Comments
 (0)