marcbachmann / node-html-pdf

This repo isn't maintained anymore as phantomjs got dreprecated a long time ago. Please migrate to headless chrome/puppeteer.
MIT License
3.56k stars 545 forks source link

adjust content to fit inside the PDF #610

Open perazzo opened 3 years ago

perazzo commented 3 years ago

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 = `

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

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?

NightLightSweden commented 2 years ago

We are also seeing this problem. Help is appreciated!

wh054 commented 2 years ago

need help

kavikumarN commented 2 years ago

need help