备忘 nodejs生产pdf 组件 node-wkhtmltopdf

阅读更多
备忘 nodejs生产pdf 组件 node-wkhtmltopdf

A Node.js wrapper for the wkhtmltopdf command line tool. As the name implies, it converts HTML documents to PDFs using WebKit.

将Html 转换成PDF


下载地址
https://github.com/devongovett/node-wkhtmltopdf
http://wkhtmltopdf.org/index.html

linux下wkhtmltopdf安装方法
http://huqiji.iteye.com/blog/2278225


第一步,下载安装wkhtmltopdf 支持

第二部 , 安装 npm install wkhtmltopdf


调用

var wkhtmltopdf = require('wkhtmltopdf');
var fs = require("fs");

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

// HTML
wkhtmltopdf('

Test

Hello world

') .pipe(res); // output to a file directly wkhtmltopdf('http://huqiji.iteye.com/', { output: 'out.pdf' }); // Optional callback wkhtmltopdf('http://huqiji.iteye.com/', { pageSize: 'letter' }, function (code, signal) { }); wkhtmltopdf('http://huqiji.iteye.com/', function (code, signal) { });

你可能感兴趣的:(javascript)