phantom-pdf and custom fonts problem

  • Hello,

    I'm using phantom-pdf recipe and I followed the tutorial for using custom fonts.
    At first I had no problems using custom fonts as specified in the documentation, but then problems started to appear in my report when using two fonts from the same family - one bold and one light.

    Strange thing is that the problem appears only on my jsreport instance - when I use the playground, everything seems OK:

    When I try the same example on my jsreport instance, I get the following result:

    As you can see, only light font is being used.

    Debug output is attached below:

    +0      Starting rendering request 29
    +3      Rendering template {shortid:rJyqsvN8-, recipe:phantom-pdf,engine:handlebars}
    +4      Data item not defined for this template.
    +6      Resources not defined for this template.
    +10     Replaced assets ["Metropolis-Light.otf","Metropolis-Bold.otf"]
    +11     Rendering engine handlebars
    +239    Compiled template not found in the cache, compiling
    +254    Replaced images []
    +257    Executing recipe phantom-pdf
    +399    Converting in dedicated phantomjs 1.9.8
    +402    Request file:///%2Ftmp%2Fjsreport-temp%2F05101080-710a-11e7-92e5-adf81a15016chtml.html
    +478    phantom-pdf recipe finished with 1 pages generated
    +479    Skipping storing report.

    Temporary HTML generated in the process of creating the final PDF and stored in my /tmp folder has correct fonts/styles applied:


    The problem is obviously in my phantom-pdf generating step, but I don't know how to debug it:(

    Any help would be appreciated!

  • Thank you for complex description.

    The reason why it works on playground is that it currently runs on windows server which has better native support for fonts.
    I tried your example on ubuntu and it doesn't work the same way it doesn't for you.

    Unfortunately I was not able to find a solution for this in my limited time. I tried to convert the bold font to woff but it didn't help. Also installing some additional font packages on ubuntu didn't help. phantomjs for some reason doesn't like this.

    If it is an option, you can use electron-pdf recipe which doesn't have this issue

    If not, I would recommend to scroll through font issues in phantomjs repository for a workaround✓

  • Thank you for your quick response Jan.

    I tried with jsreport on Windows and indeed, it works as desired. There are some obvious differences when rendering the report on Linux and Windows, but I'll edit the styles as a current workaround.

    Using electron-pdf is unfortunately not acceptable because it lacks footers/headers and page enumeration (although I can count page-break elements and create numbers myself).

    It would be great if phantom-pdf would work on Linux too, but for me it is currently a acceptable workaround to use jsreport on Windows.

    Thanks again!

Log in to reply

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