Please give a brief summary of your issue:
Converting html to pdf through webviewer server and fallback font working
Please describe your issue and provide steps to reproduce it:
We are converting html to pdf through webviewer server by using API’s. We are first uploading the html file to server and then using “GetPDF” API to convert to PDF. It does the job however there are some fonts which we want to fallback to some “Default” font lets say “Arial”.
I have added some fonts in /usr/share/fonts/truetype
and added fonts.json containing fallback font in /usr/share/fonts
but its not working.
<p style="margin:0px 0px 0.3em;"><span style="font-family:abc;">Test comic sans - default </span></p>
This text is not getting converted to default font as provided in fonts.json file.
WebViewer Server uses fonts based on what are installed on the docker container, and does not accept external font links or paths. Given that Arial is a windows font, it would not be installed with the docker. You would have to install it via a custom Dockerfile or flags yourself. You can find out how to do that via this FAQ.
The server is not defaulting to times new roman in this case, but DejaVuSans as far as I can tell. WebViewer Server does not even include times new roman in its font set.
There are ways to manually make fontconfig use specified fonts in the container. This guide specifies what to modify in Linux to make changes like this. I would apply these changes inside of the container in a similar way to how you added Arial.
You can use this in addition to fonts.json for WebViewer to achieve what you want.