We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I'm encountering difficulty rendering HTML content from an external file into a PDF within an Angular 12 application.
I have this function on a service:
` htmlFilePath = "../../pdf/pdf-component.html"
viewPDF() { html2canvas(this.htmlFilePath).then((canvas) => { const imgData = canvas.toDataURL('image/jpeg'); const imgWidth = 210; const pageHeight = 297; const imgHeight = canvas.height * imgWidth / canvas.width; let heightLeft = imgHeight; const pdf = new jsPDF('p', 'mm', "A4"); let position = 0;
pdf.addImage(imgData, 'JPEG', 0, position, imgWidth, imgHeight); heightLeft -= pageHeight; while (heightLeft >= 0) { position = heightLeft - imgHeight; pdf.addPage(); pdf.addImage(imgData, 'JPEG', 0, position, imgWidth, imgHeight); heightLeft -= pageHeight; } this.addFooters(pdf); pdf.output('dataurlnewwindow'); });
}`
htmlFilePath is just an example, can´t make it render a pdf from a different location. Any suggestions?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I'm encountering difficulty rendering HTML content from an external file into a PDF within an Angular 12 application.
I have this function on a service:
` htmlFilePath = "../../pdf/pdf-component.html"
viewPDF() {
html2canvas(this.htmlFilePath).then((canvas) => {
const imgData = canvas.toDataURL('image/jpeg');
const imgWidth = 210;
const pageHeight = 297;
const imgHeight = canvas.height * imgWidth / canvas.width;
let heightLeft = imgHeight;
const pdf = new jsPDF('p', 'mm', "A4");
let position = 0;
}`
htmlFilePath is just an example, can´t make it render a pdf from a different location.
Any suggestions?
The text was updated successfully, but these errors were encountered: