如何使用c#从pdf文件中获取书签。
哪个是最好的图书馆。
答案 0 :(得分:2)
我发现此代码使用iTextSharp从pdf文件中获取所有书签:
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());
}
}