1/72 PDFBox 值的来源是什么?

huangapple go评论83阅读模式
英文:

Where does the 1/72 PDFBox value come from?

问题

在这个示例中,72 DPI的值是来自于印刷和图像处理领域的一个常见标准。DPI代表每英寸的像素数,通常用于度量图像或打印品质的分辨率。在这里,72 DPI被用作渲染图像大小的参考点,因为它是一个常见的屏幕和打印设备分辨率标准。

以下是代码中涉及到的部分的翻译:

// 以用户空间单位表示的位置。1单位 = 1/72英寸(72 DPI时)
System.out.println("在PDF中的位置 = " + ctmNew.getTranslateX() + "," + ctmNew.getTranslateY() + "以用户空间单位表示");

// 像素中的原始大小
System.out.println("原始图像大小 = " + imageWidth + "," + imageHeight + "以像素表示");

// 以用户空间单位表示的显示大小
System.out.println("显示大小 = " + imageXScale + "," + imageYScale + "以用户空间单位表示");

// 以72 DPI渲染时的英寸中的显示大小
imageXScale /= 72;
imageYScale /= 72;
System.out.println("显示大小 = " + imageXScale + "," + imageYScale + "以72 DPI渲染时的英寸表示");

// 以72 DPI渲染时的毫米中的显示大小
imageXScale *= 25.4;
imageYScale *= 25.4;
System.out.println("显示大小 = " + imageXScale + "," + imageYScale + "以72 DPI渲染时的毫米表示");

注意:72 DPI在计算中被用作转换因子,将用户空间单位(通常是点)转换为英寸和毫米。这是一种常见的假设,但在实际应用中,可能需要根据具体的需求和设备分辨率进行调整。

英文:

I'm extracting images from the PDF page using the PDFBox. In the example I used as a basis (PrintImageLocations), the value of 72 dpi is used for calculation. My question is, where does this value 72 come from?

// position in user space units. 1 unit = 1/72 inch at 72 dpi
System.out.println("position in PDF = " + ctmNew.getTranslateX() + ", " + ctmNew.getTranslateY() + " in user space units");

// raw size in pixels
System.out.println("raw image size  = " + imageWidth + ", " + imageHeight + " in pixels");

// displayed size in user space units
System.out.println("displayed size  = " + imageXScale + ", " + imageYScale + " in user space units");

// displayed size in inches at 72 dpi rendering
imageXScale /= 72;
imageYScale /= 72;
 System.out.println("displayed size  = " + imageXScale + ", " + imageYScale + " in inches at 72 dpi rendering");

// displayed size in millimeters at 72 dpi rendering
imageXScale *= 25.4;
imageYScale *= 25.4;
System.out.println("displayed size  = " + imageXScale + ", " + imageYScale + " in millimeters at 72 dpi rendering");

答案1

得分: 1

不是最技术性的回答... 但它已经是一种“标准”有一段时间了... 这是一种武断而相当愚蠢的标准... 这里有一篇随机文章谈到了它的愚蠢性。

https://petapixel.com/2020/02/13/why-wont-the-72dpi-myth-die/

PDF更接近于像位图一样的像素集合,而不是像文本文件一样的基于令牌的文档。因此,在屏幕/页面上调整元素的大小时,它必须假定某种分辨率... 因为72dpi在图像中使用了很长时间,所以PDF也采用了这个标准。

英文:

Not the most technical of answers... but its been a "standard" for some time... one that is arbitrary and rather silly... Here's a random article that talks about its silliness.

https://petapixel.com/2020/02/13/why-wont-the-72dpi-myth-die/

PDF is closer to being a collection of pixels like a bitmap, than it is to being a token based document like a text file. So for sizing elements on the screen/page it has to assume certain resolution... Because 72dpi was so prevalent for images for so long it makes sense that pdf followed suit.

huangapple
  • 本文由 发表于 2020年7月22日 09:46:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/63025536.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定