node wkhtmltopdf create corrupted PDF in node webkit

不问归期 提交于 2019-12-04 18:42:26

I have tried following the examples on the node-wkhtmltopdf page.

First example generates a corrupted pdf file.

// URL
wkhtmltopdf('http://google.com/', { pageSize: 'letter' })
  .pipe(fs.createWriteStream('out.pdf'));

Though, this example works fine on my end.

wkhtmltopdf('http://google.com/', {output: 'out.pdf'});

You can also provide html instead of a url.

That being said, I am unable to generate a pdf within a node-webkit application. There doesn't seem to be any error, but nothing happens either.

Testing on Windows 7 64 bits.

I'd be curious to know why nothing is happening in a node-webkit application.

So, I have found a solution. I instead use https://github.com/ariya/phantomjs/blob/master/examples/rasterize.js with phantomJS and run this from node-webkit with phantomJS and it work like a charm.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!