在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:cnjon/react-native-pdf-view开源软件地址:https://github.com/cnjon/react-native-pdf-view开源编程语言:Objective-C 68.7%开源软件介绍:react-native-pdf-viewReact Native PDF View (cross-platform support) Breaking changes
Installationnpm i react-native-pdf-view --save
react-native link react-native-pdf-view
...
include ':PDFView'
project(':PDFView').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-pdf-view/android')
...
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);
}
......
} UsageFirst, require it from your app's JavaScript files with: import PDFView from 'react-native-pdf-view'; Example'use strict';
import React,{
Component
} from 'react';
import {
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
}
}); Configuration
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论