包含信息页的PDF文档。
[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将加载和存储这些值MediaBox和CropBox属性。不同的宽度和高度值下面描述作物的盒子。有关更多信息,请参考PDF格式的坐标系统。
的PDFDocumentPage类包含页面的宽度和高度以PDF单位直接从PDF文件中读取(PDF作物框)。PDF单位是1/72英寸,所以8.5 612 * 792对应的页面大小,11英寸由792/72 (612/72)。每个页面的大小以PDF单位(1/72英寸)将自动设置的宽度和高度属性。每个页面的大小英寸也是固定的,将被设置WidthInches和HeightInches属性。页面在像素的大小取决于业主文档决议。这个值可以改变用户在任何时间所以相应页面的像素大小的变化。让页面的大小像素使用当前分辨率,使用WidthPixels和HeightPixels属性。
文档的页面总数页面.Count。
每一个PDFDocumentPage对象也可以填充各种PDF本机对象位于原始PDF文档中相应的页面。当你首先创建一个PDFDocument对象从一个PDF文件,下面描述的所有集合的价值零。你可以填充对象使用的集合PDFDocument.ParsePages方法。每个页面解析将在下面描述的对象集合中发现的文件根据的价值PDFParsePagesOptions通过了的选项参数。
后ParsePages方法返回,以下属性将初始化如下:
如果PDFParsePagesOptions.Objects是指定的,那么PDFDocumentPage.Objects将填充一个集合PDFObject对象为每个对象项目页面中找到。这些物品可以文本(字符)、图片或矩形。如果没有对象中发现的物品页面,然后PDFDocumentPage.Objects将初始化一个空集合(PDFDocumentPage.Objects。计数为0)。
如果PDFParsePagesOptions.Hyperlinks是指定的,那么PDFDocumentPage.Hyperlinks将填充一个集合PDFHyperlink对象为每个链接条目页面中找到。如果没有超链接的页面,PDFDocumentPage.Hyperlinks将初始化一个空集合(PDFDocumentPage.Hyperlinks。计数为0)。
如果PDFParsePagesOptions.Annotations是指定的,那么PDFDocumentPage.Annotations将填充一个集合PDFAnnotation对象为每个注释条目页面中找到。如果没有注释在页面中,PDFDocumentPage.Annotations将初始化一个空集合(PDFDocumentPage.Annotations。计数为0)。
如果PDFParsePagesOptions.FormFields是指定的,那么PDFDocumentPage.FormFields将填充一个集合PDFFormField对象为每个表单字段条目页面中找到。如果没有表单字段在页面上,PDFDocumentPage.FormFields将初始化一个空集合(PDFDocumentPage.FormFields。计数为0)。
如果PDFParsePagesOptions.Signatures是指定的,那么PDFDocumentPage.Signatures将填充一个集合PDFSignature对象中的每个数字签名项页面。如果没有发现签名页,PDFDocumentPage.Signatures将初始化一个空集合(PDFDocumentPage.Signatures。计数为0)。
的PDFDocumentPage对象还包含ConvertPoint和ConvertRect辅助方法,可用于将一个点或一个矩形和页面/对象像素/英寸的坐标。
这个例子将PDF文档加载并解析其所有对象。例如如何画表面上这些对象在一个图像,请参考PDFDocumentPage。
使用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)
为每一个页面作为PDFDocumentPage在document.Pages
writer.WriteLine (“页面{0}”page.PageNumber)
昏暗的对象作为IList (PDFObject) = page.Objects
writer.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 (“- - - - - -”)
下一个obj
writer.WriteLine (”- - - - - - - - - - - - - - - - - - - - - -”)
昏暗的超链接作为IList (PDFHyperlink) = page.Hyperlinks
writer.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 ())
结束子
公共NotInheritable类LEAD_VARS
公共常量ImagesDir作为字符串=“C: \ LEADTOOLS21 \ Resources \图片”
结束类
帮助收藏
光栅net|C API|c++类库|HTML5 JavaScript
文档net|C API|c++类库|HTML5 JavaScript
医疗net|C API|c++类库|HTML5 JavaScript
医疗Web查看器net
188宝金博怎么下载
支持的平台上
net, Java, Android和iOS / macOS组件
C / c++类库的API
HTML5 JavaScript库
你的邮件已经发送到支持!有人应该联系!如果你的问题是紧急请回到聊天。
聊天时间:
周一——周五,上午6点等
谢谢你的反馈!
请填写表单重新开始一个新的聊天。
所有代理目前离线。
聊天时间:
周一-周五
早上8:30 - 6点
联系我们请填写这张表格,我们将通过电子邮件联系你。