question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No return on RNHTMLtoPDF.convert()

See original GitHub issue

We need to create a PDf with multiple images and some data. On the End the file has more then 10 Sites. If we create a smaller file it works without problems. On iOS it works fine but its not working on android with bigger files.

RNHTMLtoPDF.convert(options); do not return and the app stuck.

Do you have any idea how to fix that?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8

github_iconTop GitHub Comments

3reactions
lucaspiressimaocommented, Aug 12, 2020

@Finneah @MahbbRah

I had the same problem and the fix was just a permission that we should ask.

something like this should solve the problem.

let grantedConst = PermissionsAndroid.RESULTS.GRANTED

            try {
                const grantedRead = await PermissionsAndroid.request(
                  PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE,
                  {
                    title: "PDF PERMISSION",
                    message: "App need access ",
                    buttonNeutral: "Latter",
                    buttonNegative: "Cancel",
                    buttonPositive: "OK"
                  }
                );

                const grantedWrite = await PermissionsAndroid.request(
                    PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
                    {
                    title: "PDF PERMISSION",
                    message: "App need access ",
                    buttonNeutral: "Latter",
                      buttonNegative: "Cancel",
                      buttonPositive: "OK"
                    }
                  );

                
                if (grantedRead === grantedConst && grantedWrite === grantedConst) {
                    generatePDF()
                } else {
                  console.log("permission denied");
                }
              } catch (err) {
                console.warn(err);
              }
1reaction
schmidtmccommented, Sep 12, 2020

@lucaspiressimao Thanks for the Tip, but we had to choose another library. We couldn’t wait that long because this is an important part of our app. If I remember correctly I had this permission query.

What other library did you find that does html to pdf?

Read more comments on GitHub >

github_iconTop Results From Across the Web

RNHTMLtoPDF.convert(options) don't return nothing. #194
Until a few days ago it worked fine, and without problems, but from one moment to another, the PDF file is not being...
Read more >
React native html to pdf - ios - Stack Overflow
Found the answer to convert file in base64 string ... directory: 'Documents', base64: true }; let file = await RNHTMLtoPDF.convert(options);.
Read more >
How to Convert Html Strings to PDF Documents using React ...
In this library, We will share the archive for How to Convert Html Strings to ... base64, boolean, false, return base64 string of...
Read more >
How to print a Text View in React Native? - LinkedIn
... how your generated PDF looks like, the return promise of the function RNHTMLtoPDF.convert() contains the file path for the document.
Read more >
html-to-pdf-react-native - npm
Convert html strings to PDF documents using React Native with ... base64, boolean, false, return base64 string of pdf file (not recommended).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found