Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

Do you need to process or display PDF files?

Find out why you should be using IDRSolutions software

PDF to HTML conversion – matching PDF page size

52 sec read

A PDF file are designed to be resolution independent – they are defined using resolution independent units so that the page will always appear the same size whether it is printed or displayed on any device (regardless of the dpi of the output device). So what happens if you use these units when outputting to HTML canvas and CSS?

It turns out that the page is actually smaller than the PDF page when displayed at 100%. Infact the HTML page needs the values scaled to 133% to match the size of the PDF file at 100%. Then it all works correctly.

It is actually the same issue that forces us to correct for dpi between platforms in our PDF viewer. Some computers use 96 dpi and some use 72 dpi (which is where the value 1.33 comes from as it is 96 divided by 72). Printers can use values from 72 to pretty much infinity. This matters because it you draw a line which is 96 pixels on a 72 dpi display it will be 1.3 inches long but only 1 inch on a 96 dpi display.

Adobe made the very sensible decision that a PDF page should appear the same on whatever platform you use so it adjusts the page size to ‘mimic’ 96dpi as the default setting.

So if you are using HTML, 1.33 is the magical scaling to ensure things appear the same size as they would in PDF when drawn onscreen. If you are using our PDF to HTML convertor, the fix is in friday’s release.

 



Our software libraries allow you to

Convert PDF files to HTML
Use PDF Forms in a web browser
Convert PDF Documents to an image
Work with PDF Documents in Java
Read and write HEIC and other Image formats in Java
Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

How to insert an image into a PDF

Recently, we released JPedal 2023.07 which contains the ability to insert images into PDF files. All you need is a copy of JPedal, a...
Jacob Collins
18 sec read