Shrink the html content to fit a pdf page using HTML2PDF

Product: PDFNet Windows

Product Version: 9.3

Hi,
I am trying to fit a table in HTML to a single PDF page. Are there any specific options or methods that I can use when converting? without trying to change the HTML or CSS?

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:Forums:

You can set the target paper/page size of the output PDF.

https://www.pdftron.com/api/PDFTronSDK/dotnet/pdftron.PDF.HTML2PDF.html#pdftron_PDF_HTML2PDF_SetPaperSize_System_String_System_String_

Hi Ryan,

Thank you :+1:, I was able to configure the paper size. So I am trying to scale the content of the HTML to fit a page in PDF. First I tried to get the output I want using Chrome Print for the following file I have attached → SickNoteEmbededFont.txt. When I set the scale to 80 for A4 paper size, I got the output I wanted as shown in the figure. Then I tried the same settings using PDFTron. I am using .NET c# to code. But there when I set the DPI to 80 or any other value, it didn’t seem to affect the output. I couldn’t see any difference in the output.
SickNoteEmbededFont.txt (345.5 KB)


What I want is to get a similar output as Chrome print by using the scaling option.

When I set the scale to 80 for A4 paper size

How exactly do you do this in Chrome?
Screenshots please.

Hi @Ryan

Here is the screenshot.

Thank you for the clarification. That chromium print setting is not exposed.

However, I suspect you can accomplish the same using CSS. See this solution here.

Do you have a plan to expose that functionality in near future?

@Ryan Hi, Do you have a plan to expose this print setting since it’s also supported in the Chrome browser :slightly_smiling_face:?
Because changing the CSS is a bit of a task given that the CSS does not belong to us.

At this time no.

Could you elaborate on why using the Chrome Print Scale setting is important for your users?
How exactly does not having this option affect your users?

Yes, these HTMLs are actually medical records that will be read by the Medical Practitioners in Norway. And these HTMLs are provided by the Norwegian Labour and Welfare Administration. The correct format of PDF should be fitting the table on a single page which in this case expands to 2 pages. We are in the process of migrating from NReco PDF Generator to PDFTron for this HTML to PDF conversion. So the correct PDF we had 5 pages with each section fitting a single page. This might cause some issues from the users’ end as they receive a different format of PDF. Also, I am wondering why this converter.SetDPI(80) doesn’t work, since it’s coming with the HTML2PDF conversion.