itextsharp: what is the height of a regular PDF page in pixels?

淺唱寂寞╮ 提交于 2019-11-29 02:30:36

问题


What is the height of a regular PDF page in pixels?

I heard it was something like this:

Dim pgSize As New iTextSharp.text.Rectangle(595, 792)

but I am adding an image that takes up maybe half the height, and even though pgSize looks like a full page and the image takes up only half of it, I am getting a height of like 619 for the image?

I do not know if it is in the same units?


回答1:


Your page size depends on what you set it when you create the document, probably using the PageSize object (eg. PageSize.LETTER).

Once you've established that, most elements in iTextSharp use points and 1 in = 2.54 cm = 72 points.

So if you used a standard letter page (8.5x11) it would be 612 by 792.

I'm not sure I understand your second question about the image, but I believe that all the units in iTextSharp are points.




回答2:


Dim xDoc as new Document(PageSize.A4)



回答3:


iTextSharp expresses dimensions in terms of points. They use the commonly accepted standard of 72 points per inch. You asked for measurements in terms of pixels, iTextSharp uses 96 pixels per inch, or an approximate conversion of 1.3333 * points = pixels.

So if your page size is 8.5 inches x 11 inches, in pixels it would be 816 x 1056. In points it would be 612 x 792.

Note that iTextSharp defaults to a page size of A4 - which is 8.27 inches x 11.69 inches (slightly more elongated that the US Letter standard). This equates to 595 x 841 in points and 794 x 1122 in pixels.



来源:https://stackoverflow.com/questions/1910881/itextsharp-what-is-the-height-of-a-regular-pdf-page-in-pixels

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!