Embed custom font in a PDF generated from iPad Application
Asked Answered
R

2

5

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

Reflex answered 6/7, 2012 at 14:39 Comment(2)
The headline of this question doesn't really reflect the gist of its content. Maybe it could be changed to better reflect the real problem (which is not caused by a 'custom' font)?Gautier
Sure - what heading would you suggest?Reflex
G
8

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.

Gautier answered 6/7, 2012 at 22:46 Comment(7)
Thank you so very much for your help, it is extremely insightful. If you don't mind, I am not entirely convinced that it is not possible. 1) the font license states "Preview & Print" for embedding. In this case, I only need to view the pdf, so in my understanding it should allow me to view it, but not edit. 2) I have a PDF that does have the font successfully embedded in it that I am working off of to build the new PDF file. Again, thank you very much for your time on this (I upvoted) and I will happily accept your answer if I can't find a way to make this work.Reflex
This is very enlightening. I appreciate your help very much. Thank you!Reflex
I updated my question to show where I get the idea that it might be possible. Thanks!Reflex
@Reflex Garske: Did you yourself create that PDF which has the fonts embedded? Are you sure the fontfiles on iPad are exactly the identical copies of the files from the host system that created the Adobe PDFs?Gautier
They are 2 completely different fontfiles. I am an independent contractor for a company. The company provided the second (original) file. The iPad application builds the first file from scratch on the iPad, using different fontfiles. Is it possible that the company would have different licensing privileges in their fontfiles?Reflex
@TomGarske: Heh... this has happened in one of the companies I had contact to recently. Noted my mini-rant in the answer about the Corporate Identity font? They bought an expensive license (allowing the embedding) for the management board, but the cheap one (not allowing embedding) for the office workers...Gautier
As hard as it is for me to believe that a company would do something like this, you were exactly right. The brand standard is to use Trade Gothic when possible, but letters use Arial. Thank you very much for your help on this, and the very thorough explanation and discussion.Reflex
L
0

Isn't it possible to change the embedded font to another that allows embedding?

Lousewort answered 17/6, 2014 at 16:0 Comment(4)
Yes. In this case, the font was required as a brand standard, and I did solve it by changing the font.Reflex
@TomGarske Can you please tell me how to embed another font or show me a link with the explanation? I searched for it everywhere but I didn't find it.Lousewort
I haven't tried to. After this failed, I have made it a policy to only use Arial for reports. Most brand standards will accept Arial font as the leave behind for this purpose.Reflex
Thank you Tom. In my case, it's not possible to tell the client to use other fonts so I will have to find a way to use this one. I'll create a question on stackoverflow to this specification.Lousewort

© 2022 - 2024 — McMap. All rights reserved.