I update the version from 1.4.0 to 2.1.0. But PDF is not showing complete page. It is has half width content of html.
I set 1024px as a width size of html
I am also experiencing this.

Try to use percentage on html width instead of pixel.
Another one with same issue.
Duplicated issue #160
I have the same problem. Any workarounds?
Another one here with the same issue, any fixes?
@davegrix
I had some success with phantom-2.5-beta. But you need to find compiled for your OS or compile it yourself. Then, something like this:
let phantomPath = './vendor/phantomjs-2.5.0-beta-ubuntu-xenial/bin/phantomjs';
let base = 'file://' + path.resolve(`${dst}assets/`);
let width = 794, height = 1122;
pdf.create(
html,
{
width: `${width}px`,
height: `${height}px`,
border: '0px',
viewportSize: {
width,
height
},
base,
phantomPath
}).toFile(outputPDF, (err, res) => {
if (err) {
return reject(err);
}
return resolve(res);
});
Experiment with code above and you may get some good result. Width and height are important, otherwise phantom will use some weird viewport size (don't remember details, sorry)
@GendelfLugansk Thanks for this, I ended up setting zoom on my body attribute at 0.75, don't know if this is linux specific (ubuntu) but it did the trick for me.
you have to reduce the width of html to 550px.
It's working fine for me with above width
PhantomJS is no longer maintained, and version 2 is pretty bugged with regard to page size and DPI.
I would strongly recommend switching to headless chrome (see puppeteer). They've now got support for custom headers and footers too.
setting zoom to 0.75 like @davegrix said worked for me on OSX.
Most helpful comment
@GendelfLugansk Thanks for this, I ended up setting zoom on my body attribute at 0.75, don't know if this is linux specific (ubuntu) but it did the trick for me.