使用Node JS导出时,PDF从右至右截断html-pdf

时间:2018-08-10 09:30:44

标签: node.js pdf html-pdf

我在我的项目中有一个任务,将html文件转换为pdf。使用html-pdf已成功完成。但是问题是,当我在本地主机上运行pdf时,它运行正常,但是如果在开发服务器上尝试同样的操作,则pdf会从正确的角度减少。

我的pdf生成脚本是

var fs = require('fs');
var pdf = require('html-pdf');
var html = fs.readFileSync('ticket.html', 'utf8');
var options = { format: 'Letter' };

pdf.create(html, options).toFile('pdf/newpdftemplate.pdf', function(err, res) {
  if (err) return console.log(err);
});

请建议我是否需要更改任何设置或添加任何新脚本来完成此操作。

也在此处共享html脚本

<div class="pageContatiner noSelect ui-droppable slctCon" style="width: 6px; height: 500px;"><span class="bd1"></span><span class="bd2"></span><span class="bd3"></span><span class="bd4"></span><div class="ft-container"><div onmousedown="objSelection(this)" ontouchstart="objSelection(this)" id="pmObj-1" class="shape obj ft-widget" style="left: 330px; top: 118px; width: 100px; height: 100px; position: absolute;-webkit-transform:none;-moz-transform:none;-o-transform:none;transform:none;-ms-transform:none;"><svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" height="102" width="102"><rect class="svgObj" x="1" y="1" height="100" width="100" stroke="rgba(51,122,183,0.99)" stroke-width="1" fill="rgba(51,122,183,1)"></rect></svg></div><div class="ft-controls" style="top: 118.333px; left: 330px; width: 100px; height: 100px; transform: matrix(1, 0, 0, 1, 0, 0); transform-origin: 50% 50% 0px; visibility: hidden;"><div class="ft-rotator" style="transform: matrix(1, 0, 0, 1, 0, 0); transform-origin: 50% 50% 0px; top: -20px; left: 66px;"><i class="fa fa-undo" aria-hidden="true"></i></div><div class="ft-delete"><i class="fa fa-times" aria-hidden="true"></i></div><div class="ft-check"><i class="fa fa-check" aria-hidden="true"></i></div><div class="ft-scaler ft-scaler-top ft-scaler-left ft-scaler-tl"></div><div class="ft-scaler ft-scaler-top ft-scaler-right ft-scaler-tr"></div><div class="ft-scaler ft-scaler-bottom ft-scaler-right ft-scaler-br"></div><div class="ft-scaler ft-scaler-bottom ft-scaler-left ft-scaler-bl"></div><div class="ft-scaler ft-scaler-top ft-scaler-center ft-scaler-tc"></div><div class="ft-scaler ft-scaler-bottom ft-scaler-center ft-scaler-bc"></div><div class="ft-scaler ft-scaler-mid ft-scaler-left ft-scaler-ml"></div><div class="ft-scaler ft-scaler-mid ft-scaler-right ft-scaler-mr"></div><div class="ft-scaler ft-scaler-mid ft-scaler-center ft-scaler-mc"></div></div></div></div>

0 个答案:

没有答案