【发布时间】:2016-09-03 17:03:11
【问题描述】:
我正在使用 Wicked pdf gem 来创建 pdf。它在我本地工作得很好。但在生产中,它会带来严重的问题。生成了 pdf,但尽管生成了一个页面,但它生成了 14-15 页,其中包含如下数据:
")),this.$.write(e),this.$.close()},find:function(e){return new CKEDITOR.dom.nodeList(this.$.querySelectorAll(e))} ,findOne:function(e){return(e=this.$.querySelector(e))?new CKEDITOR.dom.element(e):null},_getHtml5ShivFrag:function(){var e=this.getCustomData("html5ShivFrag ");返回 e|| (e=this.$.createDocumentFragment(),CKEDITOR.tools.enableHtml5Elements(e,!0),this.setCustomData("html5ShivFrag",e)),e}}),CKEDITOR.dom.nodeList=function(e) {this.$=e},CKEDITOR.dom.nodeList.prototype={count:function(){return this.$.length},getItem:function(e){return 0>e||e>=this.$.length?null:(e=this.$[e])?new CKEDITOR.dom.node(e):null}},CKEDITOR.dom.element=function(e ,t){"string"==typeof e&&(e=(t?t.$:document).createElement(e)),CKEDITOR.dom.domObject.call(this,e)},CKEDITOR.dom.element。 get=function(e){return(e="string"==typeof e? document.getElementById(e)||document.getElementsByName(e)[0]:e)&&(e.$?e:new CKEDITOR.dom.element(e))},CKEDITOR.dom.element.prototype=new CKEDITOR .dom.node,CKEDITOR.dom.element.createFromHtml=function(e,t){var n=new CKEDITOR.dom.element("div",t);return n.setHtml(e),n.getFirst().remove()},CKEDITOR.dom.element.setMarker=function(e,t,n,i){var r=t.getCustomData("list_marker_id")||t.setCustomData("list_marker_id",CKEDITOR.tools.getNextNumber()).getCustomData("list_marker_id"),o=t.getCustomData("list_marker_names")||t. setCustomData("list_marker_names",{}).getCustomData("list_marker_names");return e[r]=t,o[n]=1,t.setCustomData(n,i)},CKEDITOR.dom.element.clearAllMarkers=function(e){for(var t in e)CKEDITOR.dom.element. clearMarkers(e,e[t],1)},CKEDITOR.dom.element.clearMarkers=function(e,t,n){var i,r=t.getCustomData("list_marker_names"),o=t.getCustomData("list_marker_id");for(i in r)t.removeCustomData(i);t.removeCustomData("list_marker_names"),n&&(t. removeCustomData("list_marker_id"),delete e[o])},function(){function e(e,t){return-1n;n++)t+=parseInt(this.getComputedStyle(a[e][n])||0,10)||0;return t}var r=document.createElement("_").classList,r="undefined"!=typeof r&&null!==String(r.add).match(/[Native code]/gi),o=/[ \n\t\r]/g;CKEDITOR.tools.extend(CKEDITOR.dom.element.prototype, {type:CKEDITOR.NODE_ELEMENT,addClass:r?function(e){return this.$.classList.add(e),this}:function(t){var n=this.$.className;return n&&(e( n,t)||(n+=" "+t)),this.$.className=n||t,this},removeClass:r?function(e){var t=this.$;retur
整个14-15页都是这样的。
这是创建pdf的方法。
def generate_supplier_commission_pdf
@start_date = params[:start_date].to_date.strftime('%d/%m/%Y')
@end_date = params[:end_date].to_date.strftime('%d/%m/%Y')
if params[:sec_filter].present?
sec_filter = true
else
sec_filter = false
end
results = get_report_results_by_type(params[:report_type], @start_date, @end_date, sec_filter)
@results = JSON.parse(results)
@type = params[:report_type].to_i
respond_to do |format|
format.html
format.pdf do
render pdf: "report",
layout: 'pdf_layout',
template: 'reports/generate_supplier_commission_pdf.html.erb',
encoding: 'UTF8',
print_media_type: true,
disposition: 'attachment',
page_size: 'letter',
orientation: 'landscape',
lowquality: 'false',
debug: true
end
end
end
像 wkhtml 路径或任何可以在代码中处理的东西都可以。我看到的唯一区别是在日志中,即在这一行之后
***************WICKED***************
Rendered reports/generate_supplier_commission_pdf.html.erb within layouts/pdf_layout (5.2ms)
服务器日志中不存在以下行。
"***************[\"/usr/bin/wkhtmltopdf\", \"-q\", \"--orientation\", \"landscape\", \"--page-size\", \"letter\", \"--encoding\", \"UTF8\", \"--lowquality\", \"--print-media-type\", \"file:///tmp/wicked_pdf20160903-24256-1v1ay70.html\", \"/tmp/wicked_pdf_generated_file20160903-24256-1da8k68.pdf\"]***************"
如果有人能指出在这种情况下出了什么问题,我将不胜感激。提前致谢。
【问题讨论】:
标签: ruby-on-rails pdf wkhtmltopdf wicked-pdf