简体   繁体   English

如何在使用jsPDF下载之前预览pdf文件

[英]How to preview pdf file before download using jsPDF

I created pdf file generator using jsPDF library .It's work fine Pdf file nicely downloading .But I need preview that pdf file before downloading 我使用jsPDF库创建了pdf文件生成器。可以很好地下载Pdf文件。但是在下载前,我需要预览该pdf文件

Here my Code 这是我的代码

 const doc = new jsPDF();
doc.text('hello world');
doc.save('test.pdf');

Can you help me? 你能帮助我吗?

There's a library called filepreview that: 有一个名为filepreview的库:

Will generate a file preview (gif, jpg or png) of about 450 different document formats. 将生成约450种不同文档格式的文件预览(gif,jpg或png)。

That includes PDF. 包括PDF。 It seems quite heavy-weight (because of all the formats it supports), but looks like it will do exactly what is required: 似乎很重(因为它支持所有格式),但是看起来它确实可以满足要求:

var filepreview = require('filepreview'); var filepreview = require('filepreview');

filepreview.generate('test.pdf', 'test_preview.png', function(error) {
  if (error) {
    return console.log(error);
  }
  console.log('File preview is test_preview.png');
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM