本文介绍了如何使用Poppler以真实比例显示PDF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对于如何以真实比例显示PDF文档感到困惑,即比例= 100%.

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

注意:我正在使用 python-poppler-qt4

Poppler-qt4提供了获取真实尺寸的方法PDF点数:

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

然后将页面呈现为QImage ,应该以每英寸点数(DPI)的形式提供图形设备的分辨率:

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)

现在,由于文档的自然大小以磅为单位(即每英寸72个),并且图像渲染器需要每英寸的点数,因此我可以假设文档的自然大小是当其分辨率为72 DPI时?还是点和点是两种不同的量度?如果我错了,那么解决办法是什么?

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?

推荐答案

PDF文件中的点是物理单位,您可以使用标尺对其进行测量.图像中的点(像素)是虚拟单位,它们之间的连接是通过分辨率因子完成的.当您将内容从向量空间移动到栅格空间时,您可以确定点与像素之间的关系(用于转换的分辨率),这取决于您的应用程序来确定100%的含义.

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.

大多数应用程序将屏幕的DPI用作100%比例的参考.在Windows上,这通常意味着96DPI,即距PDF文件1英寸的位置以96像素表示在屏幕上. Adobe Reader使您可以设置自己的分辨率以用于100%缩放,默认情况下为110DPI.

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.

这篇关于如何使用Poppler以真实比例显示PDF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 22:07