如何获取PDF页面宽度和高度? [英] How to Get PDF page width and Height?
问题描述
我有一个pdf,我想使用iTextSharp获取pdf中每页的宽度和高度?
I have a pdf , and I want to get the width and Height for each page in pdf using iTextSharp?
鉴于这是我想要使用的pdf
given this is the pdf I want to work with
string source=@"D:\pdf\test.pdf";
PdfReader reader = new PdfReader(source);
推荐答案
你想要MediaBox吗?
Do you want the MediaBox?
Rectangle mediabox = reader.GetPageSize(page);
您想要轮换吗?
int rotation = reader.GetPageRotation(page);
你想要两者的组合吗?
Rectangle pagesize = reader.GetPageSizeWithRotation(page);
你想要CropBox吗?
Do you want the CropBox?
Rectangle cropbox = reader.GetCropBox(page);
大多数都返回 Rectangle
具有 getWidth()
和 getHeight()
等方法来获取页面的宽度和高度。
其他有用的方法是 getLeft()
和 getRight()
以及 getTop()
和 getBottom()
。这四种方法返回定义页面边界的 x
和 y
坐标。
Most of them return an object of type Rectangle
that has methods such as getWidth()
and getHeight()
to get the width and the height of the page.
Other useful methods are getLeft()
and getRight()
as well as getTop()
and getBottom()
. These four methods return the x
and y
coordinates that define the boundaries of your page.
我在哪里可以找到大部分文档?
Where did I find most of this documentation?
在第6章 iText在行动中。
In chapter 6 of iText in Action.
这篇关于如何获取PDF页面宽度和高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!