PDF Viewer Widget not showing base64 encoded PDF file
-
Hien4 years ago #23075
When trying to set the “source”-Property of the PDF Viewer Widget with
“data:application/pdf;base64,<my-base64-encoded-pdf>” it does not show the PDF in my application.
However using an URL like https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf works.
I thought something similar to the ImageWidget (“data:img/png;base64,<my-base64-encoded-img>”) works.
What am I doing wrong?
Armin WinklerHas successfully completed the online course IntroductionHas successfully completed the online course Intermediate (200)Has successfully completed the online course Advanced (300)Has successfully completed the online course Basics (100)4 years ago #23243::Hello Hien,
please be sure to use the “PDFViewer_PDFJS” instead of the regular PDFViewer from UI5 since it is somewhat buggy. The former is a custom widget developed by Simplifier and is part of our Standard Content. I’ve tested it and our custom widget accepts both base 64 strings with or without the mime type part in the beginning and displays the PDF properly.
Regards,
Armin
Armin WinklerHas successfully completed the online course IntroductionHas successfully completed the online course Intermediate (200)Has successfully completed the online course Advanced (300)Has successfully completed the online course Basics (100)4 years ago #23270::Hello Alexandros,
you can download an example application from here, the download link will be valid for 30 days: https://files.simplifier.io/f/4037c92a5bd44dfe8810/?dl=1 Password is “simplifier”.
For the example to work properly, you need to configure a PDF template in the plugin’s administration UI. The example app uses a template named “SIMP_Digital_Form” and uses the configuration which you can look up from here: https://privatebin.simplifier.io/?85c1a81793b9076e#xJeUV9C1AZ1uEJltPJ73MDvOji2nvADAzpK/r04JTfw= (link valid for 30 days as well, password like above)
Regards,
Armin
Chris BouveretHas successfully completed the online course IntroductionHas successfully completed the online course Intermediate (200)Has successfully completed the online course Advanced (300)Has successfully completed the online course Basics (100)Has successfully completed the online course Advanced (320)Has successfully completed the Intermediate CertificationHas successfully completed the Advanced Certification3 years ago #27669::Hello together,
As we now have a marketplace you can find a PDF generation example to download at any time. Also, you can find articles on how to generate PDFs and to create a PDF template in our Knowledge Base.
In general, we still recommend to use the “PDFViewer_PDFJS” widget instead of the PDFViewer widget.
For me, these are the two main reasons:
1) The PDFViewer doesn’t display PDFs on mobile devices, but instead shows only the toolbar with a download button is visible. This limitation is still persistent in the current openui5 version 1.92, as you can see in the official documentation: sap.m.PDFViewer
2) If you want to use base64 as a source you have to use a data URI like “data:application/pdf;base64,<your-base64-encoded-pdf>”. Additionally, you have to whitelist this URI in advance. Example: “jQuery.sap.addUrlWhitelist(undefined, <your-dataURI>);”. For more information about whitelisting in openui5, have a look in the official documentation: URL Whitelist Filtering
I hope this clears up some questions.
Best,
Nina
You must be logged in to reply to this topic.