Merged words in pdf after saving
Author: charliearayaCreated Jun 29, 2026Updated Jun 29, 2026
I have some paragraphs inside my pdf where words get merged together. Like "Treynor ratio" becomes "Treynorratio" on the pdf. I've checked the source pdf and this is not visible there. container.innerText contains "Treynor ratio" with space.
This is how we have set up the document:
const xMargin = 15;
const yMargin = 16;
const width = 210;
const contentWidth = width - xMargin * 2; // = 180mm content area width after accounting for horizontal margins
const windowWidthInPixels = 1060; // HTML renderer window width should stay in CSS pixels
const doc = new jsPDF({
orientation: 'portrait',
unit: 'mm',
format: 'a4', // 210mm x 297mm || 8.27in x 11.69in
compress: true,
});
this.setupSebFonts(doc);
doc.setLanguage(language);
doc.setProperties({ title: filename });
console.log(container.innerText);
return new Promise((resolve) => {
doc.html(container.innerHTML, {
width: contentWidth,
margin: [yMargin, xMargin, yMargin, xMargin],
windowWidth: windowWidthInPixels,
autoPaging: 'text',
filename: filename,
callback: (pdf) => {
pdf.save(filename); // The file saved contains spacing issues
const blob = pdf.output('arraybuffer');
resolve(blob);
},
});
});Currently using version 4.2.1
Issues in Chrome & Edge
Looks good in Adobe Acrobat Reader
Source: parallax/jsPDF