2012-02-27 72 views
2

我想用“iTextSharp.text.pdf”获取特定PDF页面的书签信息,我发现如何在pdf中获得书签的集合,但是我想要得到它仅在PDF特定页面,这是我整个PDF代码:获取每个PDF页面的书签

public void ExportBookmarksToXml(string SourcePdfPath, string xmlOutputPath, string Password = "") 
    { 
     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()); 
     } 
    } 

,因为我想知道每一个书签,多少页,多少空白页有我需要这个, 。

谢谢!

回答

-1

使用以下代码获取pdf每一页中的所有书签。

IList<Dictionary<string, object>> bookmarks = SimpleBookmark.GetBookmark(pdfReader); 
foreach (Dictionary<string, object> bk in bookmarks) 
{ 
string bjj = bk.Values.ToArray().GetValue(0).ToString(); 
}