Node-html-pdf: Font size is significant larger in rendered pdf

Created on 17 Apr 2018  路  22Comments  路  Source: marcbachmann/node-html-pdf

Did I miss something?

My css is:

.page {
    width: 8.5in;
    height: 11in;
    font-size: 16px;
}

It works very well in real brower. But in rendered pdf file, only the 70% of the page width is visible, font-size is larger than it is in real browser. the remaining 30% is cut off.

My options object is empty, and it is same when I specify width and height

let options = {}
/* result is the same
let options = {
    width: '8.5in',
    height: '11in'
 }
*/
pdf.create(invoiceStr, options).toFile('./test.pdf', ()=> {}) 

What did miss?

Most helpful comment

Guys I found something just add to your css file this line:

html {
zoom: 0.55;
}

All 22 comments

i have the same issue. I made the entire page width reduced by half and its started working locally. But same problem after deployment in server.

@marcbachmann Can you please help here. I have my custom fonts for UI and am passing UI html to node api to generate PDF. But i am getting pdf with all weired fonts. How can i solve this

On Windows, locally executed code works fine, however when I upload to server (linux based), while styles applied correctly, all proportions are extremely big compared to original. (Font size)

Update Apparently won't get fixed it seems: See this issue

Same issue

Same issue here, more than a year has passed... is this being taken care of at all?

Same issue, tried reducing the zoom factor but not getting any changes, will this be fixed?

Same here.

same.

Same issue. On mac.

I have the same problem.

Had same issue, solved mine by using em rather than px.

Hi all, has anyone found a solution to this? Experiencing the same thing now.

Same here...

I have the same problem

Same problem

Guys I found something just add to your css file this line:

html {
zoom: 0.55;
}

Guys I found something just add to your css file this line:

html {
zoom: 0.55;
}

It's just a temporary solution. but it will work because we zoom in before render to pdf.
Any solution for this issues

Guys I found something just add to your css file this line:

html {
zoom: 0.55;
}

your workaround just saves my day

Guys I found something just add to your css file this line:
html {
zoom: 0.55;
}

your workaround just saves my day

Im glad for you man!

I had this issue with html-pdf however using node-html-pdf solved it. I am aware this issue is on node-html-pdf but am posting this here incase it helps anyone having the same issue with html-pdf - silly me did not realise they were two different libraries.

Guys I found something just add to your css file this line:

html {
zoom: 0.55;
}

Savior

Guys I found something just add to your css file this line:

html {
zoom: 0.55;
}

Thanks bro!! It works.. I did like

<html style="zoom: 0.55;">

But still searching for a permanent fix!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ZBilel picture ZBilel  路  4Comments

ascsi picture ascsi  路  3Comments

vivekiyer114 picture vivekiyer114  路  5Comments

adman020 picture adman020  路  5Comments

wobsoriano picture wobsoriano  路  3Comments