如何获取PDF页面宽度和高度? [英] How to Get PDF page width and Height?

查看:2542
本文介绍了如何获取PDF页面宽度和高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆