简体   繁体   中英

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

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:

Will generate a file preview (gif, jpg or png) of about 450 different document formats.

That includes 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');

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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