0

Long story short, I'm developing an app using (Framework7, VueJS, Cordova). I need to generate and preview a pdf file using jsPDF; this works normally when I test on the browser, but when I build the app to test it on Android, nothing happens when I try to generate the PDF.

Here are the lines responsible for the pdf generation part:

    var blobPDF =  new Blob([ doc.output() ], { type : 'application/pdf'});
    var url = window.URL.createObjectURL(blobPDF);
    window.open(url);
  • Have you tried the debugger in Chrome to see if you get any error messages? – Lubricin Dec 02 '21 at 13:28
  • No error was shown in devtools, as I said, it works fine on the browser (I can preview the generated pdf). But when I test it on my Android phone, nothing happens (The blob file is created, but when I try to preview it using window.open, nothing happens) – Mourad Bousserouel Dec 02 '21 at 13:41
  • It might be that you need to use InAppBrowser - per https://stackoverflow.com/questions/66249683/how-to-open-a-generated-blob-of-a-pdf-in-the-default-browser-in-a-cordova-app Try logging the blob. Also it seems that doc.output takes different parameters. Check that you are producing the expected value. https://artskydj.github.io/jsPDF/docs/jsPDF.html#output – Lubricin Dec 02 '21 at 14:01
  • I'm using InAppBrowser, I tested to open google.com and it worked, but when I try the blob file preview, it doesn't open on my device (although it works on my PC's browser).. Plus, I've been testing with all of jsPDF's parameters to no avail. – Mourad Bousserouel Dec 02 '21 at 14:16
  • Does this answer your question? [How can I display a pdf document into a Webview?](https://stackoverflow.com/questions/2655972/how-can-i-display-a-pdf-document-into-a-webview) – Eric Dec 02 '21 at 14:27
  • I need the app to work offline, so using Google Docs as a medium isn't an option. I think this has something to do with permissions and navigation parameters via AndroidManifest.xml and Config.xml, but I still haven't solved the issue – Mourad Bousserouel Dec 02 '21 at 15:28

0 Answers0