Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
react-native-pdf-view
Advanced tools
React Native PDF View (Android Only)
React native 0.19 changed the ReactProps class which led to problems with updating native view properties (see https://github.com/facebook/react-native/issues/5649). These errors are corrected in react-native-pdf-view version 0.2.0. Use version 0.2.* for react native >=0.19 and for earlier react native versions use version 0.1.3.
npm i react-native-pdf-view --save
android/setting.gradle
...
include ':PDFView'
project(':PDFView').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-pdf-view/android')
android/app/build.gradle
...
dependencies {
...
compile project(':PDFView')
}
On newer versions of React Native (0.18+):
import com.keyee.pdfview.PDFView; // <--- import
public class MainActivity extends ReactActivity {
......
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new PDFView(), // <------ add here
new MainReactPackage());
}
}
On older versions of React Native:
import com.keyee.pdfview.PDFView; // <--- import
public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {
......
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mReactRootView = new ReactRootView(this);
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.addPackage(new MainReactPackage())
.addPackage(new PDFView()) // <------ add here
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
mReactRootView.startReactApplication(mReactInstanceManager, "ExampleRN", null);
setContentView(mReactRootView);
}
......
}
First, require it from your app's JavaScript files with:
import PDFView from 'react-native-pdf-view';
'use strict';
import React,{
Component,
StyleSheet,
View
} from 'react-native';
import PDFView from 'react-native-pdf-view';
export default class PDF extends Component {
constructor(props) {
super(props);
}
render(){
<PDFView ref={(pdf)=>{this.pdfView = pdf;}}
src={"sdcard/pdffile.pdf"}
onLoadComplete = {(pageCount)=>{
this.pdfView.setNativeProps({
zoom: 1.5
});
}}
style={styles.pdf}/>
}
}
var styles = StyleSheet.create({
pdf: {
flex:1
}
});
Property | Type | Default | Description |
---|---|---|---|
src | string | null | pdf absolute path |
pageNumber | number | 1 | page index |
zoom | number | 1.0 | zoom scale |
onLoadComplete | function | null | page load complete,return page count |
FAQs
A pdf file view component for react native.
The npm package react-native-pdf-view receives a total of 22 weekly downloads. As such, react-native-pdf-view popularity was classified as not popular.
We found that react-native-pdf-view demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.