0

Currently, we use the react-native-pdf to open a pdf returned from a server-side API, e.g. https://xxxxxx/xxxx-esb/v1/customer/getSrPdfDownload?partyId=S2444201B&srRef=MmOdI42EZLRNeUG38LyNZHk10lbv8s9-zD3lJxzJz1Tg3tS4gAfKbAxOBk36Qwgn. Different from the code sample given by react-native-pdf, copied below, it is not pointing to a pdf file with the suffix. On iOS, the pdf cannot be scrolled. Any idea why?

export default class PDFExample extends React.Component {
    render() {
        const source = {uri:'http://samples.leanpub.com/thereactnativebook-sample.pdf',cache:true};
        //const source = require('./test.pdf');  // ios only
        //const source = {uri:'bundle-assets://test.pdf'};

        //const source = {uri:'file:///sdcard/test.pdf'};
        //const source = {uri:"data:application/pdf;base64,..."};
  • Is that sample pdf working fine for you ? – Kirankumar Dafda Sep 06 '19 at 10:47
  • by right it would work. But some restriction that I can't use uri point directly to test.pdf but must use the format uri as I mentioned in the example link above – Tran Huynh Sep 06 '19 at 13:31
  • for iOS add https://stackoverflow.com/a/55565795/3840093 style={{flex: 1}} to pdf container, and also try once with [this](https://github.com/cnjon/react-native-pdf-view) plugin too, and check if it is working or not. – Kirankumar Dafda Sep 07 '19 at 05:24

1 Answers1

0

You should define a View out of your Pdf as a container. And pdf should be inside of this container.

  <View style={styles.pdf_container}>
        <Pdf
          style={styles.pdf} ...your props />
  </View>

styles.js

import { Dimensions } from "react-native"
const { width, height } = Dimensions.get("window")

  pdf_container: {
    flex: 1
  },
  pdf: {
    height: height - 100
  }
Kubilay Kiymaci
  • 472
  • 3
  • 14