DPI option doesn't seems to work

  • Hi Jsreport team!

    Here is my issue, using wkhtmltopdf recipe, I was able to generate the reports that I needed for testing. However it was on local Windows.
    Now we are starting setting up the same using Docker on Ubuntu server and that's when things started to get funny.

    I'm well aware of the difference in DPI between OSes, but it is specified (as per your documentation) that the recipe as a dpioption, setting it either in the studio or in the config.*.json did not change anything but is listed in the terminal on the debug line.

    Setting it with a wrong value cause an error though.

    Any idea?

    Thanks in advance!!

  • Hm, there is likely nothing we can do here when you see the correct parameter on the command line.

    It seems the dpi currently doesn't work in wkhtmltopdf utility based on this

  • Okay I see :/ will have to look for a workarround I guess :(

    Thanks anyway!

  • If you are mainly interested in the different size of elements. You can try the adaptation using a css like this

    body {
      transform-origin: 0 0;
      -webkit-transform-origin: 0 0;
      transform: scale(0.654545);
      -webkit-transform: scale(0.654545);

  • Actually it is not only about the size of the content but display of the content does break because of the DPI difference :/

    And using your css unfortunately doesn't change anything about that break :(

    as you can see here (first is windows (the "good" one) then ubuntu (the "bad" one))0_1499870177558_firefox_2017-07-12_16-33-18.png

    (blanck space are normals!!)

    Also using the 12.3 version as in your extension not the 12.4 stable :/

  • administrators

    @MI53RE19 just for your information i use zoom instead transform: scale,

    i use the following snippet in my templates and i never had to deal with DPI problems of different OS (at least when using phantom), where Unix is a boolean value set in a script that uses the node.js os module for the detection of the OS. hopefully it can help you too.

      {{#if Unix}}
      html {
       zoom: 0.5625
      {{/if }}

  • @bjrmatos Thanks for the tip! We did found another way that could be used as well, it was to call the zoom option from wkhtmtopdf, either by setting it in the confi.*.json file or by the Docker command line:

    docker run -d -p 5488:5488 --restart always -v /path/to/jsreport:/jsreport -e "authentication:enabled=true" -e "authentication:login:password=pass" -e "wkhtmltopdf:zoom=0.78125" jsreport/jsreport:1.7.0-full

    The value for wkhtmltopdf's zoom that need to be set on linux/mac system to match windows's is 0.78125!

    Hope this can help people looking into this! And hopefully this will be fixed in wkhtmltopdf_12.5!!

  • administrators

    great! thanks for the info, i will add a note to our wkhtmltopdf docs that highlights this workaround. thnks!

  • All the pleasure! :)

  • I'ld like to add something, even if the workarround manage to "fix" the document, both output won't be exactly the same! this is moslty due to header top, and footer bottom margin (as per wkhtmltopdf options set in the studio) seems to be impacted by the zoom factor too! so you'll need to set both manually to have something more similar to originally outputted report on windows

    for an orginal margin top of 10mm and bottom of 5mm I had to set them as 44.6mm and 9mm (not perfectly the same but most likely)

    maybe it could be nice/useful to add those informations to the your documentation too? (because I'm sure people will ask about it soon or later!! xD)

  • administrators

    maybe it could be nice/useful to add those informations to the your documentation too? (because I'm sure people will ask about it soon or later!! xD)

    sure! thanks for the follow up!

Log in to reply

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.