I'm receiving a HTML for an API, I cannot change its content, but I can add styles. I created a NodeJS/Express backend to transform this HTML to a PDF. However, it is not formatted inside the PDF.
The example below shows the issue:
const pdf = require('html-pdf');
let form = `
<html>
<head>
</head>
<body>
<table>
<tr>
<td>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA</td>
</tr>
</table>
</body>
</html>
`
let options = {
format: 'Letter'
};
pdf.create(form, options).toBuffer(function(err, buffer){
res.writeHead(200, {
'Content-Type': 'application/pdf',
'Content-Length': buffer.length
});
return res.end(buffer);
});
The response is a PDF with the content outside the PDF file (image below). Is there a way to adjust the html-pdf
to fix the content?