尝试使用phantom-html2pdf nodejs将html转换为pdf。我尝试将CSS应用于输出,但是什么也没有发生。
app.get("/ph2p", function(req, res) {
var pdf = require("phantom-html2pdf");
var fs = require("fs");
fs.unlink("./file.pdf", function() {
console.log("pdf file deleted!");
});
pdf.convert(
{
'html': "htmlfile.html",
'css': "style.css",
js: "",
runnings: "",
'paperSize': { format: "A4", orientation: "portrait", border: "1cm" },
deleteOnAction: true,
runningsArgs: ""
},
function(err, result) {
result.toFile("file.pdf", function() {
console.log("pdf file created");
});
}
);
res.end("pdf checking...");
});
有人知道怎么了吗