![](/img/trans.png)
[英]How to determine an end of a page before converting html to pdf using wkhtmltopdf?
[英]Converting html page containing openlayers map to pdf via wkhtmltopdf
我有 Html 頁面包含表格和 OpenLayers 地圖一切都在所有瀏覽器甚至 IE 上正常工作。 我想將此頁面轉換為 pdf,所以我使用了 wkhtmltopdf,當我使用幕后 WebKit 讀取 wkhtmltopdf 來渲染頁面時,我測試了Qt Web 瀏覽器上的輸出,由於ol-debug.js:18601ReferenceError: Can't find variable: requestAnimationFrame
錯誤,瀏覽器拒絕顯示 OpenLayers 地圖ol-debug.js:18601ReferenceError: Can't find variable: requestAnimationFrame
ol.PluggableMap.prototype.render = function() {
if (this.animationDelayKey_ === undefined) {
this.animationDelayKey_ = requestAnimationFrame(
this.animationDelay_);
}
};
因為這個錯誤 wkhtmltopdf 只轉換 Html 表並忽略地圖
Ps:我使用這些命令進行轉換
wkhtmltopdf.exe --enable-javascript --no-stop-slow-scripts --javascript-delay 2000 --debug-javascript
對此問題的解決方法的任何想法或建議
在此先感謝您的幫助
我發現使用 Chrome headless 是將 html 轉換為 pdf 的更好和最快的選擇
C:\\Google\\Chrome\\Applicationchrome.exe --headless --disable-gpu --run-all-compositor-stages-before-draw --virtual-time-budget=2000 --print-to-pdf=C: \\newPdf.pdf https://openlayers.org/en/latest/examples/animation.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.