Anroid and Ios both show blank red box
its shows blank red box , didn't have any error in console
please help me out asap
i attached screen short ios

your RN version?
0.46
change RN to 0.45 or 0.47 try again. I have release v1.2.8 and the example use RN 0.47 is ok.
I also use RN 0.46.4 is OK, but RN 0.46.2 when click "Next" cause "this._lazyCallableModules[name] is not a function" error, draging/scrolling is OK.
It seems other modules problem. https://github.com/gcanti/tcomb-form-native/issues/370
Hey guys, I do have the same issue listed above
RN version : 0.46.4,
RNPdf version : 1.2.8
OS : Android 4.4.2
Source used ( fetched by myself with RN Fetch Blob ) : {
uri: "file:///data/data/<Domain>/files/files/d25b85fd778b59a1574a589875f483b0.pdf"
}
The box shows up but the file isn't displayed. I also tried to set the webpath of the file as URI but didn't work either.
Any help would be useful, thanks :)
@centotaure
Did you forget add SDCARD permission to AndroidManifest.xml?
Automatically add:
RNFB_ANDROID_PERMISSIONS=true react-native link react-native-fetch-blob
Manually add:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
@wonday Both permissions are on the manifest already, plus file reading/writing works with images or html files so i assume it doesn't come from there
i facing this issue too in both ios and android platform
my environment: "dependencies": { "react": "16.0.0-alpha.12", "react-native": "0.47.0", "react-native-fetch-blob": "^0.10.8", "react-native-pdf": "^1.3.0" },
I can not reproduce this problem. Do you use my sample or your app? If you use a password protected PDF and not give the password, it will show a blank. You can debug ios version by xcode, and add a break-point at wPdfView.m loadPdf() to see whether the pdf is loaded successfully or not.
I am still facing this problem my versions "react": "^16.0.0-alpha.12", "react-native": "^0.47.0", "react-native-pdf": "^1.3.1",
@shrinandhini2801
Your source version is no problem.
can you give me your app source (delete no related, the min environment that has this problem)
import React, { Component } from 'react'; import { View, StatusBar, TouchableHighlight, Text, Dimensions, Platform, Image, Button } from 'react-native'; import { connect } from 'react-redux'; import Pdf from 'react-native-pdf'; import OpenFile from 'react-native-doc-viewer'; import Header from '../../common/UI/header/Header'; import constants from '../../router/Constants'; import CustomSideMenu from '../sidemenu/customSideMenu'; import colorconfig from '../../config/ColorConfig.json';
var RNFS = require('react-native-fs'); var SavePath = Platform.OS === 'ios' ? RNFS.MainBundlePath : RNFS. DocumentDirectoryPath;
class Collaterals extends Component {
constructor(props) { super(props); this.state = { page: 1, pageCount: 1, }; this.pdf = null; this.getSourceFile = this.getSourceFile.bind(this); this.handlePressLocalFile = this.handlePressLocalFile.bind(this); }
componentDidMount() { RNFS.existsAssets('Aegon_case_study-2016.pdf').then((res) => { console.log("Aegon_case_study file exists???" + res); }); }
prePage = () => {
if (this.pdf) {
let prePage = this.state.page > 1 ? this.state.page - 1 : 1;
this.pdf.setNativeProps({ page: prePage });
this.setState({ page: prePage });
console.log(prePage: ${prePage});
}
}
nextPage = () => {
if (this.pdf) {
let nextPage = this.state.page + 1 > this.state.pageCount ? this.state.
pageCount : this.state.page + 1;
this.pdf.setNativeProps({ page: nextPage });
this.setState({ page: nextPage });
console.log(nextPage: ${nextPage});
}
}
goBack = () => { this.props.navigator.pop(); }
getSourceFile = () => { if (Platform.OS === 'ios') { return require('../../../assets/documents/mypdffilename.pdf'); } else { return { uri: "bundle-assets:/documents/mypdffilename.pdf" }; } }
render() {
let source = this.getSourceFile();
return (
<View style={{ flex: 1, backgroundColor: colorconfig.BG_LIGHT }}>
<StatusBar backgroundColor={colorconfig.THEME_DARK} barStyle={'dark-content'}
/>
<Pdf
ref={(pdf) => { this.pdf = pdf; }}
source={source}
page={1}
horizontal={false}
onLoadComplete={(pageCount) => {
this.setState({ pageCount: pageCount });
console.log(total page count: ${pageCount});
}}
onPageChanged={(page, pageCount) => {
console.log(current page: ${page});
}}
onError={(error) => {
console.log(error);
}}
style={styles.pdf}
/>
const styles = { container: { backgroundColor: colorconfig.BG_LIGHT, flex: 1, alignItems: 'center', }, btn: { flex: 0.5, margin: 5, padding: 5, backgroundColor: colorconfig.THEME_DARK, }, btnDisable: { flex: 0.5, margin: 5, padding: 5, backgroundColor: colorconfig.TEXT_COLOR_LIGHTDARK, }, btnText: { textAlign: 'center', color: '#FFF', }, pdf: { flex: 1, width: Dimensions.get('window').width, } };
/*eslint-disable */ const mapStateToProps = state => {
return ({ networkStatus: state.networkStatus, errorStatus: state.errorStatus });
}; /*eslint-enable */ export default connect(mapStateToProps)(Collaterals);
I have placed my pdf files inside android/app/src/main/assets/documents/mypdf.pdf .. But i am not able to make it work in android.
On Wed, Sep 6, 2017 at 11:53 AM, wonday [email protected] wrote:
@shrinandhini2801 https://github.com/shrinandhini2801 Your source version is no problem. can you give me your app source (delete no related, the min environment that has this problem)
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/wonday/react-native-pdf/issues/32#issuecomment-327386996, or mute the thread https://github.com/notifications/unsubscribe-auth/ATMZwUxpPY3b3rMBgAXevE65zi4dO_-nks5sfjpZgaJpZM4Otppx .
--
Shri Nandhini [image: https://]about.me/shrinandhiniJR https://about.me/shrinandhiniJR?promo=email_sig&utm_source=product&utm_medium=email_sig&utm_campaign=gmail_api
@shrinandhini2801
return { uri: "bundle-assets:/documents/mypdffilename.pdf" };
should use double "/"
return { uri: "bundle-assets://documents/mypdffilename.pdf" };
try again.
Hi ,
I have tried with double '/' also but its not working. I am trying in google pixel device .
On Wed, Sep 6, 2017 at 5:07 PM, wonday [email protected] wrote:
@shrinandhini2801 https://github.com/shrinandhini2801
return { uri: "bundle-assets:/documents/mypdffilename.pdf" }; should use double "/" return { uri: "bundle-assets://documents/mypdffilename.pdf" }; try again.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/wonday/react-native-pdf/issues/32#issuecomment-327456707, or mute the thread https://github.com/notifications/unsubscribe-auth/ATMZwYEPuAzItYv_FpP-203ID3hhsdn8ks5sfoPfgaJpZM4Otppx .
--
Shri Nandhini [image: https://]about.me/shrinandhiniJR https://about.me/shrinandhiniJR?promo=email_sig&utm_source=product&utm_medium=email_sig&utm_campaign=gmail_api
Hi team ,
Finally it worked.
On Wed, Sep 6, 2017 at 6:37 PM, Shri Nandhini [email protected] wrote:
Hi ,
I have tried with double '/' also but its not working. I am trying in google pixel device .
On Wed, Sep 6, 2017 at 5:07 PM, wonday [email protected] wrote:
@shrinandhini2801 https://github.com/shrinandhini2801
return { uri: "bundle-assets:/documents/mypdffilename.pdf" }; should use double "/" return { uri: "bundle-assets://documents/mypdffilename.pdf" }; try again.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/wonday/react-native-pdf/issues/32#issuecomment-327456707, or mute the thread https://github.com/notifications/unsubscribe-auth/ATMZwYEPuAzItYv_FpP-203ID3hhsdn8ks5sfoPfgaJpZM4Otppx .
--
Shri Nandhini [image: https://]about.me/shrinandhiniJR https://about.me/shrinandhiniJR?promo=email_sig&utm_source=product&utm_medium=email_sig&utm_campaign=gmail_api
--
Shri Nandhini [image: https://]about.me/shrinandhiniJR https://about.me/shrinandhiniJR?promo=email_sig&utm_source=product&utm_medium=email_sig&utm_campaign=gmail_api
the same with #46 , thanks @shrinandhini2801 for the hint. The project maybe not correctly linked. Do not use "rnpm install", you should use "react-native link".
after "react-native link" you can manually check the project files. In android MainApplication.java should have:
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RCTPdfView(), //should have this line
new RNFetchBlobPackage() //should have this line
);
}
};
in ios Xcode: you should have found that react-native-pdf has been added to the project.