Tag: pdfkit

保存PDFKit中间件显示的PDF文件

如果有人有兴趣将PDF文件保存在PDFKit中间件gem所显示的文件系统中,那么这里是…… 覆盖middleware.rb文件的call方法。 在覆盖中只需替换此行: body = PDFKit.new(translate_paths(body, env), @options).to_pdf 同 pdf = PDFKit.new(translate_paths(body, env), @options) file = pdf.to_file(‘Your/file/name/path’) Mymodel.my_method() #You can write your method here to use that file body = pdf.to_pdf #Here you can change the response body 如果您不想提供pdf响应,还可以覆盖response-body和content-type。 如果您有任何进一步的查询,请继续。 这个过程真的很有帮助,因为当你在视图文件中使用大量的JavaScript时, render_to_string方法将无法工作,即它不会渲染繁重的JavaScript。

由于“wkhtmltopdf”,PDFKIT显然无法正常工作

我在从HTML页面生成PDF时遇到问题。 我正在使用PDFkit。 在安装它的过程中,我注意到我需要wkhtmltopdf。 所以我也安装了它。 我做了PDFkit的文档所说的所有内容..现在我在尝试加载PDF时遇到此错误。 这是错误: command failed: “/usr/local/bin/wkhtmltopdf” “–margin-right” “0.75in” “–page-size” “Letter” “–margin-top” “0.75in” “–margin-bottom” “0.75in” “–encoding” “UTF-8” “–margin-left” “0.75in” “–quiet” “-” “-” 知道这可能是什么吗? 谢谢

PDF生成使用PDFKit和wkhtmotopdf挂起

我在OSX Lion上使用自制软件附带的wkhtmtopdf(0.9.9),突然之间我再也无法生成PDF了。 当我在URL的末尾添加.pdf时,wkhtmltopdf进程会启动,但该进程永远不会完成。 我怀疑这是wkhtmltopdf的问题,因为当我通过cli运行它时,该过程没有完成。 当我发出以下命令时,我得到一个test.pdf文件,但该过程永远不会完成,即使它说“完成”。 我能做些什么来强制完成这个过程吗? curl google.com | wkhtmltopdf – test.pdf % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 219 100 219 0 0 1685 0 –:–:– –:–:– –:–:– 5475 Loading page (1/2) Printing pages (2/2) Done