本文介绍了将自定义字体嵌入从iPad应用程序生成的PDF中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

概述

我正在使用自定义字体Trade Gothic的iPad应用程序中生成四页PDF文档.它已正确嵌入到应用程序中,并且看起来很棒.

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.

但是,该应用程序的一部分是通过电子邮件发送PDF,以免被遗忘.此发送的文件将所有字体显示为默认的sans类型,在一些系统上,我收到错误找不到或创建字体'RVYPRT + TradeGothicLTStd-Light'.某些字符可能无法正确显示或打印.

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.

我正在使用UIKit框架生成PDF.这是使用相同过程的教程: http://www.ioslearner.com /generate-pdf-programmatically-iphoneipad/

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/

我的问题

如何将字体嵌入PDF输出中,以便在发送后将其正确显示为自定义字体,而不是默认字体.

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.

提前谢谢!

更新1:我发现了类似的未解决问题

Update 1: Similar unanswered questions I have found

IOS在PDF中嵌入字体

iOS Quartz在pdf中嵌入字体

更新2:有关字体的更多信息

字体 http://store1.adobe.com/cfusion/store/html/index.cfm?store=OLS-US&event=displayFont&code=TRDQ10003000 ,它是一种OpenType字体,并允许嵌入许可证.

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.

如果PDF文件中缺少某些字体,Adobe Acrobat和Adobe Reader将自动尝试使用这些程序中内置的多种主要"字体之一来模拟缺少的字体.这样,文档将无法完全按照设计者的意愿来表示,但是至少文本不会重排.为此使用的多个主字体是: Adob​​e Serif MM Adob​​e Sans MM

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

来源: http://www.prepressure.com/pdf/basics/fonts

更新3:字体在PDF中被引用,但未嵌入

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:

我看到的第一个问题是该字体实际上是OpenType字体时被列为Type 1.正如预期的那样,实际字体"是Sans MM(找不到嵌入式字体时使用的字体.)

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.)

更新4::在另一个PDF(使用Adobe而不是iPad应用程序生成)中,所需的字体被嵌入为子集.我不确定,但是这使我相信,应该可以通过编程方式做同样的事情.

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.

推荐答案

您使用的字体看起来很棒", TradeGothic ,不允许嵌入PDF(或其他)文档中,根据其许可证.

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

(为什么字体设计师想做到这一点超出了我的头脑.毕竟,他们出售了将其用于文档的许可证,不是吗?-以及为什么[正如我最近亲身经历的那样]一家大公司会围绕一种这样的字体设计企业标识,但随后太便宜"并仅购买不允许嵌入的字体许可,因此迫使其员工向客户发送糟糕的PDF只会使他们更加疯狂.这个故事...)

从第二次更新中可以看出,您已经发现了这一事实.

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字体具有不同的风格.有些使用(内部)TrueType成形技术,有些使用Type1/PostScript方法.这就解释了为什么您看到它声明为Type1.
  2. 否,该应用程序 试图嵌入字体(但这样做不正确)" .宁可在字体文件中 HONOR 'not embed'标志,这设置了很大的限制.
  3. 那些发出有关警告的PDF接收系统"找不到或创建字体'RVYPRT + TradeGothicLTStd-Light.某些字符可能无法正确显示或打印"有过错.他们只是...

  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...

  • ...本地没有安装该字体,或者
  • ...没有可用的Adobe Multiple Master字体技术,或者
  • ...不要使用Adobe Reader或Acrobat(其中包含MM内容).
  • ...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. 始终将所有字体嵌入到PDF中.(除非您有充分的理由不这样做并知道后果).
  2. 切勿购买(或使用)不允许嵌入的字体.(并且,如果您不知道如何为此检查当前字体,请向问题.)
  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.)


更新:

基本上,嵌入标记"可以表示四个(重要)不同级别的限制. (实际上,此标志仅适用于TrueType和OpenTypes,不适用于更老式的PostScript Type1字体.从技术上来讲:此标志的名称为 fsType ,它是一个 bitmask ,并且包含在TrueType和OpenType字体的 OS/2 表中.)

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....)

这些级别指定了类型铸造厂允许在何时何地嵌入字体(不仅是PDF,而且还嵌入了Word,OpenOffice或任何其他文档类型:

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. 不允许嵌入.
    您可以在安装了字体的系统上创建电子文档,可以对其进行编辑和查看.嗯,您也可以打印它:Adobe PostScript打印机驱动程序将在PostScript文件中包括打印所需的所有字体元素.就是这样.
  2. 预览和仅打印嵌入.
    文档已嵌入字体,并且可以使用原始字体查看文档(即使在文档接收系统上也可以).但是您不能做很多其他事情(例如,不进行文档编辑),这会使整个文档变为只读+仅打印.可以将内容复制并粘贴到另一个文档中,但是它将不使用(甚至不传送)受限制的字体.
  3. 可编辑的嵌入.
    可以编辑文档(在接收系统上).但是,此操作的确切成功取决于是否嵌入了 full 字体或 subset .如果您的子集偶然不包含"i",则无法添加注释白痴!".到文档中,您可能需要限制自己为傻瓜"!....
  4. 可安装的嵌入.
    这里没有限制.甚至可以提取嵌入的字体并将其安装在接收系统上. (曾经有一段时间,Microsoft会自动在收件人计算机上的Word文档中安装任何嵌入文档的字体(如果尚不存在).)但是,此选项没有意义:常规"应用程序可为提取或安装嵌入式文档字体.
  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 eitherextracting 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软件本身完全不包含 fsType 标志,则会将该字体视为允许仅打印+预览嵌入的字体. >.

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.

有关此主题的详细信息,可以从 关于面向第三方开发人员的字体嵌入指南"的Adobe白皮书 .

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

这篇关于将自定义字体嵌入从iPad应用程序生成的PDF中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 08:10