[Html2PdfConverter] Generated PDF content not scale to full A4 page size

[Html2PdfConverter] Generated PDF content not scale to full A4 page size

  
Forge Component
(51)
Published on 26 Sep (4 weeks ago) by Guilherme Pereira
51 votes
Published on 26 Sep (4 weeks ago) by Guilherme Pereira

Dears,

I am able to generate PDF using htmltoPdfconverter, the Page is created from SimpleReports as shown below,

After Generating the PDF, using the HTMLtoPDFconverter method GeneratePDF, the pdf generated is shown below,


I have tried all the optional arguments,

SyntaxEditor Code Snippet

"-T 0 -R 0 -B 0 -L 0 -s A4 --print-media-type --disable-smart-shrinking --no-background "


Still getting the same response.


Please help in fixing this issue.


Hi Sathish,

Three questions.

1. The output PDF has an A4 page and is the content that is shrinking or the page itself has a bigger format?

2. What are the orientation? Landscape or Portrait?

3. Does your page have any CSS style applyed that can be impacting the PDF output?

By default, the page size is already A4, so you shouldn't need to set it.

Hi Eduardo,

Please find the answers below,

1) The output PDF is A4 page and the content is shrinking

2) Portrait

3) I am calling GeneratePDF inside Preparation and passing to Download, please find the screenshots below,


Any ideas/suggestions in fixing this.

Thanks.


Eduardo Jauch wrote:

Hi Sathish,

Three questions.

1. The output PDF has an A4 page and is the content that is shrinking or the page itself has a bigger format?

2. What are the orientation? Landscape or Portrait?

3. Does your page have any CSS style applyed that can be impacting the PDF output?

By default, the page size is already A4, so you shouldn't need to set it.



Hello Sathish,

As you are already setting

--disable-smart-shrinking

And the page IS A4, I would try to identify any style being applied through CSS that can be causing this.

A search in the web also tells that sometimes, beside the above, you also need to set the DPI to it to work as expected.

Cheers.

Hi guys,

I know this post is quite old, but when I was searching for other issues about pdf and I found this and I knew what was wrong in the Sathish scenario.

Analysing the screens I saw he was using SimpleReports with PDF. But Simple Reports has different layouts to screens orientations. In that example, he was using the layout for Portrait and trying to print only change the pdf orientation.  The right way is changing the layout of his report to use Landscape and after that print pdf in landscape.  


Cheers

Fabio



  

Dear Fabio,

Both the Report and the PDF is A4 Portrait only, but the Content is not scale to A4 Portrait. (Both my screenshots are A4 Portraits)

Please, you can try to use the sample A4 Portrait Report given with the Simple Reports module, and try to convert to HTMLTOPDF converter, it will still not scale properly.

(Sample Report given below, A4 Portrait)

 http://rafaelfantato.outsystemscloud.com/SimpleReports/


Any ideas/suggestions in fixing this.

Thanks.


Fábio Fantato wrote:

Hi guys,

I know this post is quite old, but when I was searching for other issues about pdf and I found this and I knew what was wrong in the Sathish scenario.

Analysing the screens I saw he was using SimpleReports with PDF. But Simple Reports has different layouts to screens orientations. In that example, he was using the layout for Portrait and trying to print only change the pdf orientation.  The right way is changing the layout of his report to use Landscape and after that print pdf in landscape.  


Cheers

Fabio



  



Hi, Sathish!

My component was not made for html2pdf, but to export PDF by browser directly.

The Wkhtml that is used to generate PDF not support a lot of CSS advanced I used in my component.

The good new is that I'm developing an update for my component to include an embed DLL to export and with that a support to a new CSS to adapt the page size.

If you can't wait for that, you can try change a little bit of my CSS code (where I use cm instead px). Try to put a smaller size or %.

 

Other hint is:

"-T 0 -R 0 -B 0 -L 0 -s A4 --print-media-type --disable-smart-shrinking --no-stop-slow-scripts"

Remove that code part that prevent background color in elements

--no-background

And add this to prevent errors with many pages:

--no-stop-slow-scripts