16
Views
2
Comments
[Html2PdfConverter] Encounter CSS Formatting issue when using HTML2PDFConverter
Forge component by Miguel 'Kelter' Antunes
72
Published on 02 Jun 2020
Application Type
Traditional Web

Hi, I am using Html2PdfConverter to convert a HTML into PDF. Below was my step


  1. Created a Web Block to generate all the content needed.
    1. Content are table record list generated from SQL widget (statements are executing stored procedure)
    2. Have created some CSS class to format the tables layout
  1. Created a HTML page using Screen and added in the Web Block. This HTML page will be use to generate the content of PDF.
    1. Have created some CSS class to format the layout of the Screen
  1. Created a HTML landing page using Screen for users to generate pdf using Link widget.


Widget Tree


Properties


  1. In that landing page, have created a Screen Action to generate PDF using HtmlToPdfConverter logic in Html2PdfConverter extension.

Generate PDF (Flow) : 

  • SetRequestTimeout2 :
    • Action: SetRequestTimeout
    • Timeout: 1800 (seconds)
  • Assign : Set Page Footer html page that we are going to use for the PDF (a URL) and the localorgs for HtmlToPdfConverter settings
    • Page Footer variable: "https://" + GetServerName() + GetOwnerURLPath() + "PageFooter.aspx"
    • Localorgs variable: “"-O Landscape --no-print-media-type --background --footer-font-size 10 --footer-html " + pdfFooter +" --footer-right ""[page] "" " ”
  • HtmlToPdfConventer :
    • OtherArgs = localorgs
    • URL = url of the screen created in step 2.
  • Download :
    • File content = HtmlToPdfConventer.Binary
    • File Name = CurrDate()+"_slides.pdf"
    • Mime-Type = “application/octet-stream”


Flow diagram :


But the exported PDF file not in proper formatting

It should be something like this:

Appreciate that if can help to identify the root cause.

Thanks.

Rank: #719

Hi @Roger Jou, we've also encountered the same problem in HTMLtoPDFConverter. In our case, the root cause is the Content-Security Policy of the application is turned on. Please refer to this thread.

We tried all the solution to fix the CSP issue of the extension but with no luck.

As an alternative extension, we use UltimatePDF and so far we are not encountering CSS formatting problem even if the CSP is turned on.

Hope this helps,

Thank you