使用iTextSharp获取PDF页面大小(Get PDF page size with iTextSharp)
我有一个PDF文档,我刚刚通过文件上传(InputFile)收到。
我想在继续之前使用iTextSharp来检查它的页面大小。 例如,当您转到文件>属性>描述选项卡>页面大小(在acrobat中)时,pdf的大小。
有关如何做到这一点的任何建议?
谢谢!
I have a PDF document that I just received via file upload (InputFile).
I'd like to use iTextSharp to check it's page size before proceeding. For example, the size of a pdf when you go to file > Properties > Description Tab > Page Size (in acrobat).
Any advice on how I can do that?
THANKS!
最满意答案
您需要从输入流中读取pdf。
PdfReader reader = new PdfReader(m); PdfImportedPage page = writer.GetImportedPage(reader, i); // size information //page.PageSize.Width //page.PageSize.HeightYou need to read the pdf from your input stream (m).
PdfReader reader = new PdfReader(m); // Page size Rectangle pagesize = reader.GetPageSize(1);更多推荐
发布评论