我正在使用Wicked pdf gem来创建pdf。它在我的本地绝对正常。但在生产方面,这给了严重的问题。生成pdf但是尽管生成了单个页面,但它生成了14-15页,其数据如下:
")),这。$。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 =此$ 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()。除去()},CKEDITOR.dom.element.setMarker =函数(E,T,N,I){风险 R = t.getCustomData(" list_marker_id&#34)|| t.setCustomData(" list_marker_id",CKEDITOR.tools.getNextNumber())。getCustomData(" list_marker_id&#34) O = t.getCustomData(" list_marker_names&#34)|| t.setCustomData(" list_marker_names",{})getCustomData(" list_marker_names");返回 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 =函数(例如,T,N){风险 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"),删除e [o])},function(){function e(e,t){ return-1<("" + e +"")。replace(o,"")。indexOf("" + T +" ")}函数t(e){var t =!0; return e。$。id ||(e。$。id =" cke_tmp _" + CKEDITOR.tools.getNextNumber(), t =!1),function(){t || e.removeAttribute(" id")}}函数n(e,t){var n = CKEDITOR.tools.escapeCss(e。$。id );返回"#&#34 + N +" " + t.split(/,\ s * /)。join(",#" + n +"")} function i(e){for( VAR t = 0时,n = 0时,I = A [E]。长度;我将N; N ++)T + = parseInt函数(this.getComputedStyle(一个并[e] [N])|| 0,10)|| 0;返回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)),这。$。className = n || t,this},removeClass:r?function(e){var t =此$; 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\"]***************"
如果有人能指出在这种情况下出了什么问题,我将非常感激。提前谢谢。
答案 0 :(得分:0)
我设法通过在config/environments/production.rb
# config.assets.js_compressor = :uglifier
并在其中添加此行:
config.assets.compress = true