Some test text!

Self serving substitute fontskeyboard_arrow_down

Self serving substitute fonts

WebViewer will automatically use substitute fonts hosted on a web server when a font is not embedded in the document. The fallback fonts are hosted by PDFTron by default but if this is a concern, you can host the fonts on your own servers. You can also customize the font package to better suit your needs.

To get started, please download the self serve font package.

Serving the default font package from your server

Simply expand the webfont archive into a location that is accessible via URL, and set the custom font URL within your WebViewer config file using


See this guide for more details about config files.

WebViewer will first download fonts.json (which serves as a catalogue of available fonts and matching rules), then it will choose the approriate fonts to download as needed.

Customizing the font set

It is possible to add new fonts to the webfont backend, and it's possible to customize the matching behaviour. However it is very important that fonts.json closely matches the actual list of available fonts -- if the character set coverage in fonts.json is incorrect, or if it points to font files that do not exist, the stability of WebViewer could be compromised. For this reason, we've made a command-line tool that can be used to safely modify the font set.

Please download the webfont creation tool for Linux, Mac, or Windows (only 64 bit versions of these tools are available at this time).

Example: add Lato and Raleway to the list of supported fonts

First, download some variants of the fonts "Lato" and "Raleway", available self serve font package. Expand this archive into WebFontSource/ alongside the already expanded webfont archive.

Then run the WebFontCreator CLI tool on your gathered files using the command line ./WebFontCreator --output ./WebFontDest --base ./WebFontSource/fonts.json --fonts ./WebFontSource This will place a newly generated fonts.json file into ./WebFontDest along with compressed versions of all the fonts. This new fonts.json will be the same as ./WebFontDest/fonts.json, except that it will now contain descriptions and matching rules for Lato and Raleway.

At this point ./WebFontDest is suitable to serve directly as a custom webfont backend for webviewer (using CoreControls.setCustomFontURL())

Example: use Lato as the primary fallback font

fonts.json has two main components: fontList, a list of the available fonts on the server, and matchPatterns, which tells the office worker how to select the correct font from fontList. At this point fontList should have an entry for Lato, with the id lato1.

The matching algorithm works its way down matchPatterns in order, looking for a match for the font family name. A fallback font is something that matches any family name. So if the algorithm makes it all the way through the list without finding a match, we want to put the universal match at the bottom, to catch any misses.

We do this using the match type All. There are already some All matches at the end of the list, and to add Lato as the primary fallback, we simply place the object


towards the bottom of matchPatterns, but before any other match with type All

Get the answers you need: Support


Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.