How to Get PDF page width and Height?

我的梦境 提交于 2019-12-29 08:32:14

问题


I have a pdf , and I want to get the width and Height for each page in pdf using iTextSharp?

given this is the pdf I want to work with

string source=@"D:\pdf\test.pdf";
PdfReader reader = new PdfReader(source); 

回答1:


Do you want the MediaBox?

Rectangle mediabox = reader.GetPageSize(page); 

Do you want the rotation?

int rotation = reader.GetPageRotation(page);

Do you want the combination of both?

Rectangle pagesize = reader.GetPageSizeWithRotation(page);

Do you want the CropBox?

Rectangle cropbox = reader.GetCropBox(page);

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?

In chapter 6 of iText in Action.



来源:https://stackoverflow.com/questions/18202660/how-to-get-pdf-page-width-and-height

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