Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Render portrait and landscape page with same width? #898

Open
ryuzascarlet opened this issue Dec 19, 2024 · 0 comments
Open

How to Render portrait and landscape page with same width? #898

ryuzascarlet opened this issue Dec 19, 2024 · 0 comments

Comments

@ryuzascarlet
Copy link

What react-native version are you using?
0.76.5

What react-native-pdf version are you using?
^6.7.6

What platform does your issue occur on? (android/ios/both)
android

Is it possible to render page with different orientation (first page portrait and second page landscape) to render with same width like in the second picture. My project is the first picture

1st picture
APP TEST

2nd picture
SamsungApp

Show us the code you are using?

export default function App() {
  const pickDocument = async () => {
    let result = await DocumentPicker.getDocumentAsync({
      type: "application/pdf",
    });
    // console.log(result.uri);
    console.log(
      "NEW LOG=========================================================================="
    );
    console.log(result.assets[0].uri);
    // seturipdf(result.assets[0].uri);
    seturipdf({ uri: result.assets[0].uri });
  };

  const onlineSource = {
    uri: "http://samples.leanpub.com/thereactnativebook-sample.pdf",
    cache: false,
  };

  const [uripdf, seturipdf] = useState(null);

  return (
    <View style={styles.container}>
      <StatusBar animated={false} backgroundColor={"black"}></StatusBar>
      <Text>Open up App.js to start working on your app!</Text>
      <Button
        title="Check Document Picker"
        onPress={() => console.log(uripdf)}
      ></Button>
      <Button
        title="Check OnlineSource"
        onPress={() => console.log(onlineSource)}
      ></Button>
      <Button title="Pick Document" onPress={pickDocument}></Button>
      {uripdf != null ? (
        <Pdf
          trustAllCerts={false}
          source={uripdf}
          onLoadComplete={(numberOfPages, filePath) => {
            console.log(`Number of pages: ${numberOfPages}`);
          }}
          onError={(error) => {
            console.log(error);
          }}
          onPressLink={(uri) => {
            console.log(`Link pressed: ${uri}`);
          }}
          style={styles.pdf}
        />
      ) : (
        <Pdf
          trustAllCerts={false}
          source={onlineSource}
          onLoadComplete={(numberOfPages, filePath) => {
            console.log(`Number of pages: ${numberOfPages}`);
          }}
          onError={(error) => {
            console.log(error);
          }}
          onPressLink={(uri) => {
            console.log(`Link pressed: ${uri}`);
          }}
          style={styles.pdf}
        />
      )}

    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center",
  },
  pdf: {
    flex: 1,
    alignSelf: "stretch",
  },
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant