如何以编程方式阅读PDF书签 [英] How to read PDF bookmarks programmatically

查看:150
本文介绍了如何以编程方式阅读PDF书签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用PDF转换器访问PDF中的图形数据。一切工作正常,除了我没有得到一个书签的列表。是否有可以读取PDF书签的命令行应用程序或C#组件?我发现iText和SharpPDF库,我目前正在通过他们。

I'm using a PDF converter to access the graphical data within a PDF. Everything works fine, except that I don't get a list of the bookmarks. Is there a command-line app or a C# component that can read a PDF's bookmarks? I found the iText and SharpPDF libraries and I'm currently looking through them. Have you ever done such a thing?

推荐答案

尝试以下代码

PdfReader pdfReader = new PdfReader(filename);

IList<Dictionary<string, object>> bookmarks = SimpleBookmark.GetBookmark(pdfReader);

for(int i=0;i<bookmarks.Count;i++)
{
    MessageBox.Show(bookmarks[i].Values.ToArray().GetValue(0).ToString());

    if (bookmarks[i].Count > 3)
    {
        MessageBox.Show(bookmarks[i].ToList().Count.ToString());
    }
}

注意:不要忘记添加iTextSharp DLL您的专案。

Note: Don't forget to add iTextSharp DLL to your project.

这篇关于如何以编程方式阅读PDF书签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆