【问题标题】:Angular 1 export html to pdf with css?Angular 1 使用 css 将 html 导出为 pdf?
【发布时间】:2018-04-03 06:15:57
【问题描述】:

我有一个任务,我需要将 html 导出为 pdf。pdf 应该具有与浏览器中相同的设计。基本上我需要 css 也应该在 pdf 文件中工作。我在前端使用 angularjs。

【问题讨论】:

    标签: angularjs


    【解决方案1】:

    Here is Plunker首先在cmd上运行pdfSample.js为--node pdfsample.js 然后在您想要获取 pdf 的工作区中包含 html 和 js 文件。然后尝试像你一样运行。它会工作。

       pdf.create(renderedHtml, options).toStream(function (err, stream) {
    
        res.setHeader('Content-type', 'application/pdf');
        console.log("*****inside pdf create ******");
    
        stream.pipe(res);
       stream.pipe(fs.createWriteStream('invoice.pdf'));
    });
    

    【讨论】:

      【解决方案2】:

      您可以使用 html-pdf 这里是链接 node-html-pdf 和示例示例 see Example 。我遵循了示例示例,并且能够生成 pdf,是的,您也可以使用 css。

      【讨论】:

      • 你能告诉我你的例子吗,实际上我使用的是 angular 1,我对 angular 很陌生。所以实际上我被卡住了......
      猜你喜欢
      • 2016-09-19
      • 2015-04-14
      • 1970-01-01
      • 1970-01-01
      • 2018-12-25
      • 2018-06-12
      • 1970-01-01
      • 2015-09-25
      • 2013-08-25
      相关资源
      最近更新 更多