README
react-native-react-native-android-pdfview
Getting started
$ npm install react-native-android-pdfview --save
dependencies "react-native": "^0.41.2 ",
Mostly automatic installation
$ react-native link react-native-android-pdfview
Manual installation
iOS
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-android-pdfview
and addRNReactNativeAndroidPdfview.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNReactNativeAndroidPdfview.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)<
Android
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.reactlibrary.RNReactNativeAndroidPdfviewPackage;
to the imports at the top of the file - Add
new RNReactNativeAndroidPdfviewPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native--android-pdfview' project(':react-native-android-pdfview').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-android-pdfview/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-android-pdfview')
Windows
- In Visual Studio add the
RNReactNativeAndroidPdfview.sln
innode_modules/react-native-android-pdfview/windows/RNReactNativeAndroidPdfview.sln
folder to their solution, reference from their app. - Open up your
MainPage.cs
app
- Add
using React.Native.Android.Pdfview.RNReactNativeAndroidPdfview;
to the usings at the top of the file - Add
new RNReactNativeAndroidPdfviewPackage()
to theList<IReactPackage>
returned by thePackages
method
Usage
import RNReactNativeAndroidPdfview from 'react-native-react-native-android-pdfview';
RNAndroidPdfView:
load pdf usage :
uri: you need send the PDF file's name
<RNAndroidPdfView uri={"moby.pdf"} style={{width:Dimensions.get('window').width,height:Dimensions.get('window').height}}/>
url:
<RNAndroidPdfView url={"........url"} style={{width:Dimensions.get('window').width,height:Dimensions.get('window').height}}/>
if you want to get the PDF from intent and get the complete state ,
Usage :
componentDidMount() {
this.listener = null;
if (Platform.OS === 'ios') {
//todo
} else {
this.listener = DeviceEventEmitter.addListener("complete", (result) => {
this.showAlert("获取到加载结束的通知" + result); //result is a boolean : true
});
}
}
if you want the RNAndroidPdfView work ,please add
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
into Mainfest............
At last : if an error occurred liked "Mainfest merge failed" ,you need add some things like down:
add xmlns:tools="http://schemas.android.com/tools" in <mainfest />
add tools:replace="android:allowBackup" in <application />