Question

I am getting confused as to how to display a PDF document in its true scale, i.e. scale = 100%.

NB: I am using python-poppler-qt4.

Poppler-qt4 provides a method to get the true size of the PDF in points:

document = Poppler.Document.load('mypdf.pdf')
page = document.page(0)
size = page.pageSize() # returns a QSize object

Then to render the page into a QImage, one should provide the resolution of the graphics device, in dots per inch (DPI):

image = page.renderToImage(72, 72)

Now since the natural size of the document is provided in points (i.e. 72 per inch), and the image renderer requires dots per inch, can I just assume that the natural size of the document is when its resolution is at 72 DPI? Or are dots and points two different measures? If I am wrong, then what is the solution to this?

Was it helpful?

Solution

The points in a PDF file are physical units, you can measure them with a ruler. The dots (pixels) in the image are virtual units and the connection between them is done through the resolution factor. When you move the content from vector space to raster space you decide the relation between points and pixels (the resolution used for conversion), it is up to your application to decide what 100% means.

Most applications use the DPI of the screen as reference for 100% scale. On Windows this usually means 96DPI, one inch from your PDF file is represented on 96 pixels on the screen. Adobe Reader lets you set your own resolution to be used for 100% scale and by default it is 110DPI.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top