←选择平台

PDFDocumentPage类

总结

包含信息页的PDF文档。

语法
c#
VB
c++
Java
[SerializableAttribute ()]公共PDFDocumentPage
< SerializableAttribute () >公共PDFDocumentPage
公共PDFDocumentPage
[SerializableAttribute ()]公共ref类PDFDocumentPage
讲话

PDFDocumentPage类的类型PDFDocument.Pages收集。

PDFDocument.Pages时自动创建一个新的集合PDFDocument对象的创建PDFDocument(字符串文件名)PDFDocument(文件名字符串,字符串密码)构造函数。这个集合是只读的,不能修改PDFDocument对象是一个PDF文件的只读视图。集合中的每一项对应于一页的PDF文档。

中的每一项页面集合对应于一个页的PDF文档。所以项目索引0是第一页的属性,项指数1第2页的属性等等。即使PDFDocumentPage结构包含PageNumber属性指定页面的数量,这些信息只是为了方便,PDFDocument构造函数总是填充集合以正确的顺序从第一次到最后一页。

每一个PDF文档页面包含两个矩形区域,媒体盒和作物盒。的PDFDocumentPage将加载和存储这些值MediaBoxCropBox属性。不同的宽度和高度值下面描述作物的盒子。有关更多信息,请参考PDF格式的坐标系统

PDFDocumentPage类包含页面的宽度和高度以PDF单位直接从PDF文件中读取(PDF作物框)。PDF单位是1/72英寸,所以8.5 612 * 792对应的页面大小,11英寸由792/72 (612/72)。每个页面的大小以PDF单位(1/72英寸)将自动设置的宽度高度属性。每个页面的大小英寸也是固定的,将被设置WidthInchesHeightInches属性。页面在像素的大小取决于业主文档决议。这个值可以改变用户在任何时间所以相应页面的像素大小的变化。让页面的大小像素使用当前分辨率,使用WidthPixelsHeightPixels属性。

文档的页面总数页面.Count。

每一个PDFDocumentPage对象也可以填充各种PDF本机对象位于原始PDF文档中相应的页面。当你首先创建一个PDFDocument对象从一个PDF文件,下面描述的所有集合的价值。你可以填充对象使用的集合PDFDocument.ParsePages方法。每个页面解析将在下面描述的对象集合中发现的文件根据的价值PDFParsePagesOptions通过了的选项参数。

ParsePages方法返回,以下属性将初始化如下:

PDFDocumentPage对象还包含ConvertPointConvertRect辅助方法,可用于将一个点或一个矩形和页面/对象像素/英寸的坐标。

例子

这个例子将PDF文档加载并解析其所有对象。例如如何画表面上这些对象在一个图像,请参考PDFDocumentPage

c#
VB
使用Leadtools;使用Leadtools.Codecs;使用Leadtools.Pdf;使用Leadtools.WinForms;公共无效PDFDocumentPageExample (){字符串pdfFileName = Path.Combine (LEAD_VARS.ImagesDir,@“Leadtools.pdf”);字符串txtFileName = Path.Combine (LEAD_VARS.ImagesDir,@“LEAD_pdf.txt”);/ /打开文档使用(PDFDocument文档=PDFDocument (pdfFileName)){/ /解析所有页面的一切PDFParsePagesOptions选项= PDFParsePagesOptions.All;文档。ParsePages(选项1 1);/ /将结果保存到文本文件进行检查使用(StreamWriter作家= File.CreateText (txtFileName)){foreach(PDFDocumentPage页面document.Pages){writer.WriteLine (“页面{0}”,page.PageNumber);IList < PDFObject >对象= page.Objects;writer.WriteLine (“对象:{0}”,objects.Count);foreach(PDFObject obj对象){writer.WriteLine (“ObjectType: {0}”obj.ObjectType.ToString ());writer.WriteLine (“范围:{0},{1},{2},{3}”,obj.Bounds。离开了,obj.Bounds。前,obj.Bounds。对,obj.Bounds.Bottom);WriteTextProperties(作家,obj.TextProperties);writer.WriteLine (“代码:{0}”,obj.Code);writer.WriteLine (“- - - - - -”);}writer.WriteLine (”- - - - - - - - - - - - - - - - - - - - - -”);IList < PDFHyperlink >超链接= page.Hyperlinks;writer.WriteLine (“超链接:{0}”,hyperlinks.Count);foreach(PDFHyperlink超链接超链接){writer.WriteLine (“超链接:{0}”,hyperlink.Hyperlink);writer.WriteLine (“范围:{0},{1},{2},{3}”,hyperlink.Bounds。离开了,hyperlink.Bounds。前,hyperlink.Bounds。对,hyperlink.Bounds.Bottom);WriteTextProperties(作家,hyperlink.TextProperties);}writer.WriteLine (”- - - - - - - - - - - - - - - - - - - - - -”);}}}}私人静态无效WriteTextProperties (StreamWriter作家,PDFTextProperties textProperties){writer.WriteLine (“TextProperties。FontHeight: {0}”textProperties.FontHeight.ToString ());writer.WriteLine (“TextProperties。FontWidth: {0}”textProperties.FontWidth.ToString ());writer.WriteLine (“TextProperties。FontIndex: {0}”textProperties.FontIndex.ToString ());writer.WriteLine (“TextProperties。IsEndOfWord: {0}”textProperties.IsEndOfWord.ToString ());writer.WriteLine (“TextProperties。IsEndOfLine: {0}”textProperties.IsEndOfLine.ToString ());writer.WriteLine (“TextProperties。颜色:{0}”textProperties.Color.ToString ());}静态LEAD_VARS{公共常量字符串ImagesDir =@“C: \ LEADTOOLS21 \ Resources \图片”;}
进口Leadtools进口Leadtools.Codecs进口Leadtools.Pdf进口Leadtools.WinForms公共PDFDocumentPageExample ()昏暗的pdfFileName作为字符串= Path.Combine (LEAD_VARS.ImagesDir“Leadtools.pdf”)昏暗的txtFileName作为字符串= Path.Combine (LEAD_VARS.ImagesDir“LEAD_pdf.txt”)“打开文档使用文档作为PDFDocument =PDFDocument (pdfFileName)对所有页面的解析一切昏暗的选项作为PDFParsePagesOptions = PDFParsePagesOptions。所有文档。ParsePages(选项,1,1)检查的结果保存到文本文件中使用作家作为StreamWriter = File.CreateText (txtFileName)每一个页面作为PDFDocumentPagedocument.Pageswriter.WriteLine (“页面{0}”page.PageNumber)昏暗的对象作为IList (PDFObject) = page.Objectswriter.WriteLine (“对象:{0}”,对象。)每一个obj作为PDFObject对象writer.WriteLine (“ObjectType: {0}”obj.ObjectType.ToString ())writer.WriteLine (“范围:{0},{1},{2},{3}”,obj.Bounds。离开了,obj.Bounds。前,obj.Bounds。对,obj.Bounds.Bottom)WriteTextProperties(作家,obj.TextProperties)writer.WriteLine (“代码:{0}”obj.Code)writer.WriteLine (“- - - - - -”)下一个objwriter.WriteLine (”- - - - - - - - - - - - - - - - - - - - - -”)昏暗的超链接作为IList (PDFHyperlink) = page.Hyperlinkswriter.WriteLine (“超链接:{0}”,超链接。)每一个超链接作为PDFHyperlink超链接writer.WriteLine (“超链接:{0}”hyperlink.Hyperlink)writer.WriteLine (“范围:{0},{1},{2},{3}”,hyperlink.Bounds。离开了,hyperlink.Bounds。前,hyperlink.Bounds。对,hyperlink.Bounds.Bottom)WriteTextProperties(作家,hyperlink.TextProperties)下一个超链接writer.WriteLine (”- - - - - - - - - - - - - - - - - - - - - -”)下一个页面结束使用结束使用结束私人共享WriteTextProperties (按值传递作家作为StreamWriter,按值传递textProperties作为PDFTextProperties)writer.WriteLine (“TextProperties。FontHeight: {0}”textProperties.FontHeight.ToString ())writer.WriteLine (“TextProperties。FontWidth: {0}”textProperties.FontWidth.ToString ())writer.WriteLine (“TextProperties。FontIndex: {0}”textProperties.FontIndex.ToString ())writer.WriteLine (“TextProperties。IsEndOfWord: {0}”textProperties.IsEndOfWord.ToString ())writer.WriteLine (“TextProperties。IsEndOfLine: {0}”textProperties.IsEndOfLine.ToString ())writer.WriteLine (“TextProperties。颜色:{0}”textProperties.Color.ToString ())结束公共NotInheritableLEAD_VARS公共常量ImagesDir作为字符串=“C: \ LEADTOOLS21 \ Resources \图片”结束
需求

目标平台

Leadtools.Pdf作为sembly
188金宝搏的网址客服|支持|联系我们|知识产权的通知
©1991 - 2021领先的技术公司。保留所有权利。