S
S
Samat2021-04-14 19:54:03
Angular
Samat, 2021-04-14 19:54:03

Is it possible to make a pdf preview?

I need to convert an element to an image/canvas and generate a PDF from it.
And it is very desirable that there be a preview of the pdf file or what happened
.

dom-to-image:

openPDF(): void {
    const DATA = this.paragraphsRef.nativeElement!;

    domtoimage
      .toPng(DATA)
      .then((png) => {
        const w = DATA.clientWidth;
        const h = DATA.clientHeight;
        const hpng = (h / w) * 190;
        const doc = new jsPDF('p', 'mm', 'a4');
        try {
          doc.addImage(png, 'png', 10, 10, 190, hpng, 'SLOW').output('dataurlnewwindow');
        } catch (e) {
          console.log(e.toString());
        }
      })
      .catch((err) => console.log(err));
  }


How can I pre-output what happened? Before downloading, for now I open it in a new window, but this is a bad option, because. if the file size is too big, then it just won't open

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question