wooio / htmltopdf-java

An HTML to PDF conversion library written in Java, based on wkhtmltopdf.
MIT License
172 stars 97 forks source link

Zoom #17

Closed dschm1dt closed 5 years ago

dschm1dt commented 5 years ago

Hello, when I am creating pdf's with the library the content is much smaller as if I just create it with wkhtmltopdf. I experimented with diffrent setting mechanisms and discovered that zoom has no affect at all... My code looks as follows:

HtmlToPdf.create()
        .zoom(10)
        .pageSize(PdfPageSize.A4)
        .object(HtmlToPdfObject.forHtml(html))
        .convert(destination);

Every value submitted to zoom creates the same output.

benbarkay commented 5 years ago

Seems to be related to https://bugs.launchpad.net/ubuntu/+source/wkhtmltopdf/+bug/1391456 I'll have a good look at it this weekend. Sorry for the delay in response.

benbarkay commented 5 years ago

It appears that the global settings don't have zoom as a setting property. Try using HtmlToPdfObject#zoomFactor instead, like so:

HtmlToPdf.create()
        .pageSize(PdfPageSize.A4)
        .object(HtmlToPdfObject.forHtml(html)
                        .zoomFactor(10))
        .convert(destination);

Let me know if this works out for you.

dschm1dt commented 5 years ago

Thank you, for the answer. This actually solves the problem. :)

Only for completeness, I am working on macOs 10.14.2, and with zoomFactor(3.1f) the resulting pdf looks like converted directly with wkhtmltopdf.

Developer74 commented 1 year ago

It appears that the global settings don't have zoom as a setting property. Try using HtmlToPdfObject#zoomFactor instead, like so:

HtmlToPdf.create()
        .pageSize(PdfPageSize.A4)
        .object(HtmlToPdfObject.forHtml(html)
                        .zoomFactor(10))
        .convert(destination);

Let me know if this works out for you.

Hi, can you please say solution to add custom pagesize and add headers and footer to it