本文介绍了阅读pdf页面的书签c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在尝试使用iTextSharp.text.pdf获取特定pdf页面的书签信息,我找到了如何在pdf中获取书签的集合,但我想只获取特定页面在pdf中,这是我的entayer代码pdf:



public void ExportBookmarksToXml(string SourcePdfPath,string xmlOutputPath,string Password =)

< pre lang =c#> {

PdfReader reader = new PdfReader(SourcePdfPath,new System.Text.ASCIIEncoding()。GetBytes(Password));

IList< Dictionary< string,object>> bookmarks = SimpleBookmark.GetBookmark(reader);

using(MemoryStream memoryStream = new MemoryStream())

{

SimpleBookmark.ExportToXML(bookmarks, memoryStream,ISO8859-1,true);

//MessageBox.Show(bookmarks [0] .Values.ToString());

File.WriteAllBytes(xmlOutputPath ,memoryStream.ToArray());

}

}< / pre>我需要这个,因为我想知道每个书签多少页和多少空白它拥有的页面。



谢谢!

I'm trying to get the bookmarks information of a specific pdf page with "iTextSharp.text.pdf", i found how to get a collection of the bookmarks in a pdf, but i want to get only for a specific page in a pdf, this is my code for the entayer pdf:

public void ExportBookmarksToXml(string SourcePdfPath, string xmlOutputPath, string Password = "")
<pre lang="c#"> {
PdfReader reader = new PdfReader(SourcePdfPath, new System.Text.ASCIIEncoding().GetBytes(Password));
IList<Dictionary<string, object>> bookmarks = SimpleBookmark.GetBookmark(reader);
using (MemoryStream memoryStream = new MemoryStream())
{
SimpleBookmark.ExportToXML(bookmarks, memoryStream, "ISO8859-1", true);
//MessageBox.Show(bookmarks[0].Values.ToString());
File.WriteAllBytes(xmlOutputPath, memoryStream.ToArray());
}
}</pre>I need this, because I want to know for every bookmark how many pages and how many blank pages it has.

Thanks!

推荐答案

What you can do right now is to create a function that returns a hashtable or a dictionary with the file names (string) being the keys and the pages to extract (integer array) being the values. Once you have this hashtable/dictionary, you can modify the ExtractPdfPage sub such that it will create a single new pdf file and then loop trhu the hashtable/dictionary to extract the pages and add them o the output pdf. It's just a matter of setting up the loop right such that in each loop, you read an entry and extract pages from that file.


这篇关于阅读pdf页面的书签c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 17:59