简体   繁体   English

我无法让rails插件wicked_pdf工作

[英]I can't get rails plugin wicked_pdf to work

I wanted to create PDFs for my rails application using wkhtml2pdf and wicked_pdf. 我想使用wkhtml2pdf和wicked_pdf为我的rails应用程序创建PDF。
I downloaded and extracted wkhtml2pdf beta 4 and placed it in /usr/local/bin/wkhtml2pdf 我下载并提取了wkhtml2pdf beta 4并将其放在/ usr / local / bin / wkhtml2pdf中
I tried running it on a web site and it gave a nice result. 我尝试在网站上运行它,结果很好。

In my rails application (2.3.4) I installed wicked_pdf: 在我的rails应用程序(2.3.4)中,我安装了wicked_pdf:

script/plugin install git://github.com/mileszs/wicked_pdf.git 脚本/插件安装git://github.com/mileszs/wicked_pdf.git
script/generate wicked_pdf script / generate wicked_pdf

Everything seemed to be ok. 一切似乎都没问题。 inside script/console I run the following - (with the following output) 在脚本/控制台内我运行以下 - (使用以下输出)

wp = WickedPdf.new

=># WickedPdf:0xb62f2c70 @exe_path="/usr/local/bin/wkhtmltopdf" =>#WickedPdf:0xb62f2c70 @exe_path =“/ usr / local / bin / wkhtmltopdf”

HTML_DOCUMENT = "<html><body>Hello World</body></html>"

=> " <html><body>Hello World</body></html>" >“ <html><body>Hello World</body></html>"

pdf = wp.pdf_from_string HTML_DOCUMENT

=> "/usr/local/bin/wkhtmltopdf - - -q" >> / usr / local / bin / wkhtmltopdf - - -q“

=> "\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n" =>“\\ n \\ n \\ n \\ n \\ n \\ n \\ n \\ n \\ n \\ n”

of course this isn't good. 当然这不好。 According to the test the result of my last command should start with "%pdf-1.4" 根据测试,我的上一个命令的结果应该以“%pdf-1.4”开头

Any idea what I can do? 知道我能做什么吗?

Having the same problem. 有同样的问题。 Removed the -q option from the wicked_pdf.rb file on line 19 and then was able to get the proper string on the console. 从第19行的wicked_pdf.rb文件中删除了-q选项,然后能够在控制台上获取正确的字符串。

=> "%PDF-1.4\n1 0 obj\n<<\n/Title ...

This also seems to have solved other problems. 这似乎也解决了其他问题。 The PDF still didn't render correctly when using it from the web site - embedded font issue - on to the next issue now. 从网站(嵌入式字体问题)使用PDF到现在的下一个问题时,PDF仍无法正确呈现。

Hopefully this will work for you. 希望这对你有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM