我无法让 Rails 插件 wicked_pdf 工作
我想使用 wkhtml2pdf 和 wicked_pdf 为我的 Rails 应用程序创建 PDF。
我下载并提取了 wkhtml2pdf beta 4 并将其放置在 /usr/local/bin/wkhtml2pdf
我尝试在网站上运行它,结果很好。
在我的 Rails 应用程序 (2.3.4) 中,我安装了 wicked_pdf:
脚本/插件安装 git://github.com/mileszs/wicked_pdf.git
脚本/生成 wicked_pdf
一切似乎都很好。 在脚本/控制台内,我运行以下命令 - (具有以下输出)
wp = WickedPdf.new
=># WickedPdf:0xb62f2c70 @exe_path="/usr/local/bin/wkhtmltopdf"
HTML_DOCUMENT = "<html><body>Hello World</body></html>"
=>; "Hello World"
=>
pdf = wp.pdf_from_string HTML_DOCUMENT
; “/usr/local/bin/wkhtmltopdf - - -q”
=> "\n\n\n\n\n\n\n\n\n\n"
当然这不好。根据测试,我最后一个命令的结果应该以“%pdf-1.4”开头
知道我能做什么吗?
I wanted to create PDFs for my rails application using wkhtml2pdf and wicked_pdf.
I downloaded and extracted wkhtml2pdf beta 4 and placed it in /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:
script/plugin install git://github.com/mileszs/wicked_pdf.git
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"
HTML_DOCUMENT = "<html><body>Hello World</body></html>"
=> "<html><body>Hello World</body></html>"
pdf = wp.pdf_from_string HTML_DOCUMENT
=> "/usr/local/bin/wkhtmltopdf - - -q"
=> "\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"
Any idea what I can do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
遇到同样的问题。从第 19 行的
wicked_pdf.rb
文件中删除了-q
选项,然后能够在控制台上获取正确的字符串。这似乎也解决了其他问题。从网站使用 PDF 时仍然无法正确呈现 - 嵌入字体问题 - 现在转到下一问题。
希望这对你有用。
Having the same problem. Removed the
-q
option from thewicked_pdf.rb
file on line 19 and then was able to get the proper string on the console.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.
Hopefully this will work for you.