How to check if a pdf page has a bookmark?

前端 未结 2 1457
执笔经年
执笔经年 2021-01-28 07:34

I\'m trying to check if a page in a pdf file has a bookmark and what is in that bookmark, I\'m using \"iTextSharp.text.pdf\" for reading and manipulating a pdf, but I can\'t fin

相关标签:
2条回答
  • 2021-01-28 08:09
    IList<Dictionary<string, object>> bookmarks = SimpleBookmark.GetBookmark(pdfReader);
    foreach (Dictionary<string, object> bk in bookmarks)
    {
    string bjj = bk.Values.ToArray().GetValue(0).ToString();
    

    Use This.

    0 讨论(0)
  • 2021-01-28 08:27

    You can extract the page for each bookmark from the Page key in each bookmark dictionary.

    For example:

    public bool isBookmarked(string pdfSourceFile, int pageNumber)
    {
        var reader = new PdfReader(pdfSourceFile, new System.Text.ASCIIEncoding().GetBytes(""));
        var bookmarks = SimpleBookmark.GetBookmark(reader);
        foreach (var bookmark in bookmarks)
            if (Int32.Parse(bookmark["Page"].ToString().Split(' ')[0]) == pageNumber)
                return true;
    
        return false;
    }
    
    0 讨论(0)
提交回复
热议问题