如何使用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());
        }
    }