'PDF generation via jsPDF printing full width of the page
jsPDF is generating a right hand margin. How do you control this?
The HTML text does not have the margin
Settings in jsPDF don't seem to matter. The angular method is
public pdfLetter(): void {
this.downloaderLoader.loading();
let pdfContent = document.querySelector('main[role=main]');
const fileNameElement = document.querySelector('.block-field-blocknodecerttitle span')
const dateString = new Date().toISOString().slice(0, 10).replace(/-/g, '');
let fileName = dateString + 'cbi-letter.pdf'
if (fileNameElement) {
fileName = dateString + fileNameElement.innerHTML.replace(/[^A-Za-z0-9]/gi, '-');
}
if (!pdfContent) {
this.downloaderLoader.unLoading()
return;
}
let pdf = new jsPDF('p', 'pt', 'a4');
// No difference
pdf.setFontSize(10);
// No difference
pdf.setDisplayMode("fullwidth", "continuous","FullScreen");
// Width no difference
pdf.html(pdfContent.innerHTML, {
autoPaging: true,
width: 210,
margin: 15,
x: 0,
y: 0,
callback: (pdf) => {
pdf.save(fileName);
}
});
this.downloaderLoader.unLoading()
}
CSS/SASS is setting the width to full width
.cert-certificate-letter
font-size: 12px
line-height: 1rem
main
margin-left: 10mm
margin-right: 10mm
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|


