如何使用C#来获得PDF文件的书签 [英] How to get pdf file bookmarks using c#
本文介绍了如何使用C#来获得PDF文件的书签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用C#从pdf文件的书签。
How to get bookmarks from the pdf file using c# .
这是做到这一点的最好的图书馆。
Which is the best library that do this .
推荐答案
我发现这个code获得使用iTextSharp的从PDF文件的所有书签:
i found this code to get all bookmarks from a pdf file using iTextSharp:
public void ExportBookmarksToXml(string SourcePdfPath, string xmlOutputPath, string Password = "")
{
PdfReader reader = new PdfReader(SourcePdfPath, new System.Text.ASCIIEncoding().GetBytes(Password));
//Collection of bookmarks
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());
}
}
这篇关于如何使用C#来获得PDF文件的书签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文