911
Views
12
Comments
[Html2PdfConverter] Generated PDF content not scale to full A4 page size 
Question
Forge component by Miguel 'Kelter' Antunes
72
Published on 02 Jun 2020

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.


mvp_badge
MVP
Rank: #6

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.

mvp_badge
MVP
Rank: #6

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.

mvp_badge
MVP
Rank: #46

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



  

mvp_badge
MVP
Rank: #84

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
Rank: #53513

https://rafaelfantato.outsystemscloud.com/SimpleReports/

The output PDF file from here also didn't scale to the full A4 size

Rank: #53513

Direct print to printer also yield the same output: Didn't scale to the full A4 size. There's a lot of blank spaces on the right and bottom part

Rank: #53513

I managed to solve it. Turns out that the problem was caused by the print scale that my browser is using (it was 70%). I changed it to Shrink to Fit and voila. I got what I wanted

mvp_badge
MVP
Rank: #84

Sorry my late. I'm glad you saw your print browser config. Often it is that.