Answer the question
In order to leave comments, you need to log in
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));
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question