2017-05-16 236 views
0

我需要從HTML和CSS代碼生成Node.js服務器中的PDF文件。JSreport和Node.Js:如何生成PDF文件

我在本地主機Nginx服務器上安裝了JSreport,它似乎做我想做的事情:我進入網絡軟件,它接收HTML和CSS代碼並生成PDF文件。

Jsreport

現在的Node.js服務器接收參數(如人名),然後它必須調用JSreport產生從HTML文件,我所做的PDF文件。

回答

1

如果你想在外部進程中運行jsreport服務器,您可以使用jsreport客戶的NodeJS遠程渲染PDF格式。

var client = require("jsreport-client")(url, username, password) 
client.render({ 
    template: { content: "hello {{:someText}}", recipe: "html", 
       engine: "jsrender" }, 
    data: { someText: "world!!" } 
}, function(err, response) { 
    response.body(function(body) { 
     //prints hello world!! 
     console.log(body.toString()); 
    }); 
}); 

見多文檔
https://jsreport.net/learn/nodejs-client

運行jsreport並在同一節點應用你的應用程序也被描述在這裏文檔 https://jsreport.net/learn/adapting-jsreport