Skip to content

React-native 0.78 cant render the pdf on iOS #919

Open
@husnaintahir

Description

@husnaintahir

Tested on iOS 18.0, not sure if any other OS has the problem.

import React from 'react';
import type {PropsWithChildren} from 'react';
import {
  ScrollView,
  StatusBar,
  StyleSheet,
  Text,
  useColorScheme,
  View,
  SafeAreaView,
  Dimensions,
} from 'react-native';
import Pdf from 'react-native-pdf';

function App(): React.JSX.Element {
  const source = {
    uri: 'https://file-examples.com/storage/feb7c2eda267d3071a102e4/2017/10/file-sample_150kB.pdf',
    cache: false,
  };
  return (
    <SafeAreaView style={{flex: 1, backgroundColor: '#adf'}}>
      <View style={{flex: 1, backgroundColor: '#fda', padding: 22}}>
        <Pdf
          source={source}
          onLoadComplete={(numberOfPages, filePath) => {
            console.log(`Number of pages: ${numberOfPages}`);
          }}
          onPageChanged={(page, numberOfPages) => {
            console.log(`Current page: ${page}`);
          }}
          onError={error => {
            console.log(error);
          }}
          onPressLink={uri => {
            console.log(`Link pressed: ${uri}`);
          }}
          onLoadProgress={progress => {
            console.log(`Loading progress: ${progress}`);
          }}
          style={styles.pdf}
        />
      </View>
    </SafeAreaView>
  );
}

const styles = StyleSheet.create({
  pdf: {
    flex: 1,
    width: Dimensions.get('window').width,
    height: Dimensions.get('window').height,
  },
});

export default App;

The component tree
Image

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions