使用严峻的格言,用红宝石打造pdf到png

时间:2017-01-09 05:50:53

标签: ruby pdf png

我使用grim

运行以下代码进行pdf到png的转换
 pdf = Grim.reap(File.dirname(__FILE__)<<"/pdf.pdf")
 count = pdf.count
 pdf[3].save('like.png')
 text = pdf[3].text

 pdf.each do |page|
   puts page.text
 end

显示以下错误:

  

没有这样的文件或目录 - gs -dNODISPLAY -q -sFile =。/ pdf.pdf   C:/Ruby200/lib/ruby/gems/2.0.0/gems/grim-1.3.0/lib/pdf_info.ps(Errno :: ENOENT)   来自C:/Ruby200/lib/ruby/gems/2.0.0/gems/grim-1.3.0/lib/grim/image_magic   k_processor.rb:21:in count' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/grim-1.3.0/lib/grim/pdf.rb:35:i n count'   来自pdfpng.rb:18:在''“

1 个答案:

答案 0 :(得分:0)

看起来Ghostscript依赖项缺失,因为它提供了gs二进制文件,或者您确实安装了它,但PATH中没有它。