如何使用C#获取pdf文档的高度和宽度 [英] How to get height and width of pdf document using C#

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

问题描述

我有多页数的Pdf文件

例如:A.Pdf有6页

B.Pdf有20页



我想获得pdf文件的高度和宽度



我尝试过使用Itextsharp但它不适用于我







请帮我这个



我尝试过:



I have Pdf document with multiple page count
For ex: A.Pdf have 6 pages
B.Pdf have 20 page

I want to get height and width of pdf document

I have tried using Itextsharp but its not working for me



Please help me on this

What I have tried:

iTextSharp.text.pdf.PdfReader pdfReader = new iTextSharp.text.pdf.PdfReader(fileNames[i]);

                    
                    Rectangle psize = pdfReader.GetPageSize(1);







和输出为:






and output is:

Rectangle: 612x792 (rot: 0 degrees)





我想以英寸为单位输出



I want to get output in inches

推荐答案

矩形宽度和高度以磅为单位。



一英寸有72点。



因此,您需要将返回值除以72以获得以英寸为单位的大小(8.5×11)。
The rectangle width and height are measured in points.

There are 72 points to an inch.

Therefore, you need to divide the returned values by 72 to get the size in inches (8.5" × 11").


这篇关于如何使用C#获取pdf文档的高度和宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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