我正在寻找一个可以在linux上运行的免费库(Java/Ruby),并且可以从PDF中提取图像和注释; 类似于CGPDFDocument在OS X上可以做的事情.
谢谢!
小智 6
我不知道图像,但使用最新版本的ruby pdfreader库我能够成功地从一个大的PDF文件中提取注释:
PDF::Reader.open(filename) do |reader|
reader.pages.each do |page|
annots_ref = page.attributes[:Annots]
actual_annots = reader.objects[annots_ref]
if actual_annots && actual_annots.size > 0
actual_annots.each do |annot_ref|
actual_annot = reader.objects[annot_ref]
unless actual_annot[:Contents].nil?
puts "Page #{page.number},"+actual_annot[:Contents].inspect
end
end
end
end
end
Run Code Online (Sandbox Code Playgroud)
我想可以用它来提取图像.