+-
java – 提取PDF注释/注释
我们有一个非常复杂的打印工作流程,其中控件是使用Adobe Reader或Adobe Acrobat为生成的PDF文档的草稿版本添加注释和注释.作为工作流程的一部分,应解析带有注释和注释的导入PDF文档,并将注释导入CMS系统(与PDF一起).

问:有没有可靠的工具(首选的Python或Java)来提取这些数据
干净可靠的PDF文件方式?

最佳答案
这段代码应该可以胜任. One of the answers到问题 Parse annotations from a pdf对于让我编写下面的代码非常有帮助.它使用poppler库来解析注释.这是 annotations.pdf的链接.

import poppler, os.path

path = 'file://%s' % os.path.realpath('annotations.pdf')
doc = poppler.document_new_from_file(path, None)
pages = [doc.get_page(i) for i in range(doc.get_n_pages())]

for page_no, page in enumerate(pages):
    items = [i.annot.get_contents() for i in page.get_annot_mapping()]
    items = [i for i in items if i]
    print "page: %s comments: %s " % (page_no + 1, items)

产量

page: 1 comments: ['This is an annotation'] 
page: 2 comments: [' Please note ', ' Please note ', 'This is a comment in the text'] 

安装

在Ubuntu上安装如下.

apt-get install python-poppler
点击查看更多相关文章

转载注明原文:java – 提取PDF注释/注释 - 乐贴网