[PDF Generator Plugin] Complex UI HTML to PDF

Forge Component
(7)
Published on 2019-08-28 by Experts
7 votes
Published on 2019-08-28 by Experts

Hi guys,


I have a complex UI in Mobile app (HighChart, Icon, Lots of custom CSS, ...), and I want to export the page into PDF file.


What I have in mind is converting HTML content into the PDF file. However, we have to put everything in a single HTML file. The tricky part is I have no idea of how to create that HTML file because the UI is so complex and when I inspect the UI code, I see SVG tag, and some generated tags by OS, along with separated CSS files. I don't know how to put everything into a single HTML file.


I think we are not able to generate PDF by URL because, in the Mobile app, we have no URL, right?


Is there any simple way to achieve this? Thanks in advance.

Hi Minh,

Why do you think you have no URL? 

An OutSystems mobile in the end is just a set of HTML, CSS and Javascript files running in a Cordova container. 

You can get a current page url by calling GetBookmarkableURL() 

Regards,

Daniel

Hi Daniel,


I got this error when using GetBookmarkableURL():


java.lang.IllegalStateException: printing is already pending
at kf0.onWrite(PG:26)
at android.print.PDFtoBase64$3.onLayoutFinished(PDFtoBase64.java:107)
at kf0.onLayout(PG:4)
at android.print.PDFtoBase64.process(PDFtoBase64.java:118)
at com.pdf.generator.PDFPrinterWebView.onPageFinished(PDFPrinterWebView.java:108)
at nn.b(PG:2)
at Ke0.handleMessage(PG:66)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7156)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)


After that, the app was crashed :(