DocRaptor

DocRaptor Does Typekit Fonts, Too!

We wrote a series of posts on using Google fonts with DocRaptor a while back. This has proven to be a popular series for us, and we’ve often heard from users who want to add Typekit fonts to their DocRaptor PDFs. This is easy enough to do, provided you have a DocRaptor account, a Typekit account, and the proper license for the font you want to use.

First up, you’ll need to add any domain you want to use to create a PDF with Typekit fonts to your kit settings. This is the referrer that Typekit expects to find to apply the fonts from your kit correctly. For example, here’s how we’ve set this to use Myriad Pro on DocRaptor:

Adding your domain to your Typekit settings

Next, you’ll need to set “javascript” to “true” when making your POST request. This will force DocRaptor to wait until your JavaScripts have finished running on your page before attempting to turn it into a PDF. Since your Typekit fonts are loaded with JavaScript, DocRaptor can’t actually apply them correctly without setting this parameter.

Running JavaScripts in DocRaptor

Finally, you can use Typekit with DocRaptor using both document_content and document_url. Both methods work as expected, with some very minor implementation differences. Let’s check it out!

Typekit’s Javascript depends on your domain URL being set correctly. Typically, this will be the URL you’ve added your Typekit fonts to, but if you’re sending us raw HTML, you can’t actually check the referrer. Never fear – you can simply set this URL when making your POST request. Here’s how it works:

Setting referrer when making a POST request

This parameter must pass a correct URL, otherwise your Typekit fonts won’t actually be applied.

Your other option is to send us an existing URL via document_url. No need to pass referrer in this case, as the URL you’re sending us will already be referenced in your Typekit settings.

And you’re done! Your PDFs never looked so good.

Disclaimer: DocRaptor is not affiliated with Adobe Products in any way, and you must have the proper license to use any Typekit font with DocRaptor. Here’s some more information about Typekit font licensing: Typekit font licensing