Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embed custom font in a PDF generated from iPad Application

Overview

I am generating a four page PDF document in an iPad application that uses a custom font, Trade Gothic. It is embedding correctly into the application, and looks great.

However, part of the app is to email the PDF as a leave behind. This sent file displays all font as a default sans type and on a few systems, I received the error Cannot find or create the font 'RVYPRT+TradeGothicLTStd-Light'. Some characters may not display or print correctly.

I am generating the PDF using the UIKit Framework. Here is a tutorial that uses the same process: http://www.ioslearner.com/generate-pdf-programmatically-iphoneipad/

My Question

How do I embed the font into the PDF output so that it is rendered correctly as the custom font rather than default type after it is sent.

Thanks in advance!

Update 1: Similar unanswered questions I have found

IOS embed font in PDF

iOS Quartz embed font in pdf

Update 2: More Information on fonts

The font, http://store1.adobe.com/cfusion/store/html/index.cfm?store=OLS-US&event=displayFont&code=TRDQ10003000, is an OpenType Font and does allow embedding by the license.

Also, the default font used is standard.

If certain fonts are missing from the PDF file, Adobe Acrobat and Adobe Reader will automatically try to emulate the missing font by using one of the Multiple Master fonts that are built into these programs. This way, the document will not be represented exactly as the designer wanted it to, but at least the text won’t reflow. The Multiple Master fonts that are used for this are: Adobe Serif MM and Adobe Sans MM

source: http://www.prepressure.com/pdf/basics/fonts

Update 3: Fonts are referenced in the PDF, but not embedded

It appears that the app is attempting to embed the fonts but they are not being embedded correctly. Here is a screenshot of the embedded fonts under File -> Document Properties:

enter image description here

The first problem that I see is that the font is being listed as Type 1, when it is actually an OpenType font. And as expected, the "Actual Font" is Sans MM (the font used when an embedded font is not found.)

Update 4: In another PDF (generated using Adobe, not iPad application) the fonts that are needed are embedded as subsets. I am not sure, but this leads me to believe that it should be possible to do the same thing programmatically.

enter image description here

like image 383
Tom Avatar asked Jul 06 '12 14:07

Tom


People also ask

How to embed fonts in a PDF?

Once you have opened the correct PDF in Acrobat, go to File > Document Properties. 3. Select the tab at the top that says Fonts and then look for the fonts that have (Embedded Subset) at the end of their name. These are the fonts that are already embedded.

How do I change the font in a PDF file?

Then open up the PDF in question in Adobe Acrobat and ensure you are logged in to your account. 2. Once you have opened the correct PDF in Acrobat, go to File > Document Properties. 3. Select the tab at the top that says Fonts and then look for the fonts that have (Embedded Subset) at the end of their name.

Can I use the same font for viewing and printing PDFs?

For example, your version of a font, not your print provider’s version, can always be used by the provider for both viewing and printing the PDF file.


1 Answers

The font you are using and which is 'looking great', TradeGothic, does not allow embedding into PDF (or other) documents, according to its license.

(Why a font designer would want to do that is beyond my little brain. After all they sold a license to use it for documents, no? -- And why [as I've experienced first-hand recently] a big corporation would design their Corporate Identity around one such font, but then being 'too cheap' and buying only font licenses which don't allow embedding, hence forcing their employees to send out crappy PDFs to their customers adds only more madness to this story...)

As can be seen from your second update, you have discovered that fact already.

What you seem to misunderstand is the 'Document Properties' screenshot:

  1. OpenType fonts come in different flavors. Some use (internally) the TrueType shaping technology, some use the Type1/PostScript method. That explains why you're seeing it declared as Type1.
  2. No, the app does NOT 'attempt to embed the font (but doing so un-correctly)'. It rather seems to HONOR the 'don't embed'-flag in the font file which sets that very limitation.
  3. Those PDF-receiving systems which give that warning about "Can not find or create the font 'RVYPRT+TradeGothicLTStd-Light'. Some characters may not display or print correctly" are not at fault. They simply...

    • ...don't have that font installed locally, or
    • ...don't have the Adobe Multiple Master font technology available, or
    • ...don't use Adobe Reader or Acrobat (which would have the MM stuff included).

My simple advice, repeated hundreds of times in front of my customers over the years:

  1. Always embed all fonts in your PDFs. (Unless you have a very good reason not to, and know the consequences.)
  2. Never buy (or use) a font that doesn't allow for embedding. (And if you don't know how to check your current fonts for this, get yourself some professional advice over the issue.)

Update:

Basically, the "embedding flag" can express be four (important) different levels of restrictions. (In practical terms, this flag applies to TrueType and OpenTypes only, not to the more old-fashioned PostScript Type1 fonts. Technically speaking: the name of this flag is fsType, it is a bitmask, and it is contained in the OS/2 table of TrueType and OpenType fonts....)

These levels specify where and when and for which purpose the type foundry allows embedding of the font in documents (not only PDF but also Word, OpenOffice or any other document type:

  1. No embedding allowed.
    You can create an electronic document on the system which has the font installed, you can edit it and you can view it. Ah, you can also print it: Adobe PostScript printer drivers will include all font elements required for printing in the PostScript file. But that's it.
  2. Preview & Print-only embedding.
    Document have the font embedded and document can be viewed with the original font (even on a document-receiving system). But you can't do much else with it (no document editing, for example).It makes the whole document read-only + print-only. Copy and paste of content into another document is possible, but it will NOT use (or even transfer) the restricted font.
  3. Editable embedding.
    The document can be edited (on a receiving system). However, the exact success of this operation depends on whether the full font or a subset was embedded. If your subset by accident doesn't contain an 'i', you can't add a comment 'idiots!' to the document, and you may need to restrict yourself to 'fools!'....
  4. Installable embedding.
    No restrictions here. The embedded font can even be extracted and installed on the receiving system. (There was a time when Microsoft would automatically install any document-embedded font from a Word document on the recipient machines if it wasn't already there.) Meanwhile however, this option is moot: NO 'usual' application provides means for either extracting or installing embedded document-fonts.

There are two more (less important) restrictions that the 'embedding' flag of a font may indicate:

  • No subsetting allowed (Other restriction as outlined above may apply independently.)
  • Bitmap embedding only (No outline data may be embedded.)

Adobe software in many cases, when there is no fsType flag at all contained in the font itself, will treat this font as one that allows Print + Preview-only embedding.

Details about this topic may be learned from an Adobe Whitepaper about 'Font Embedding Guidelines for Third-party Developers.

like image 124
Kurt Pfeifle Avatar answered Oct 01 '22 09:10

Kurt Pfeifle