创建多页 PDF 时出错
有人已经在 iPad 应用程序中创建了 PDF 文档吗?我看到 UIKit 中有新函数可以执行此操作,但我找不到任何代码示例。
BOOL UIGraphicsBeginPDFContextToFile (
NSString *path,
CGRect bounds,
NSDictionary *documentInfo
);
void UIGraphicsBeginPDFPage (
void
);
我找到了一个应该在 iPhone 上运行的示例,但这给了我错误:
Fri Apr 30 11:55:32 wks104.hs.local PDF[1963] <Error>: CGFont/Freetype: The function `create_subset' is currently unimplemented.
Fri Apr 30 11:55:32 wks104.hs.local PDF[1963] <Error>: invalid Type1 font: unable to stream font.
Fri Apr 30 11:55:32 wks104.hs.local PDF[1963] <Error>: FT_Load_Glyph failed: error 6.
Fri Apr 30 11:55:32 wks104.hs.local PDF[1963] <Error>: FT_Load_Glyph failed: error 6.
Fri Apr 30 11:55:32 wks104.hs.local PDF[1963] <Error>: FT_Load_Glyph failed: error 6.
Fri Apr 30 11:55:32 wks104.hs.local PDF[1963] <Error>: FT_Load_Glyph failed: error 6.
Has anyone already created a PDF document in an iPad app? I see that there are new functions in the UIKit to do this, but I can't find any code example for it.
BOOL UIGraphicsBeginPDFContextToFile (
NSString *path,
CGRect bounds,
NSDictionary *documentInfo
);
void UIGraphicsBeginPDFPage (
void
);
I found an example that is supposed to work on the iPhone, but this gives me errors:
Fri Apr 30 11:55:32 wks104.hs.local PDF[1963] <Error>: CGFont/Freetype: The function `create_subset' is currently unimplemented.
Fri Apr 30 11:55:32 wks104.hs.local PDF[1963] <Error>: invalid Type1 font: unable to stream font.
Fri Apr 30 11:55:32 wks104.hs.local PDF[1963] <Error>: FT_Load_Glyph failed: error 6.
Fri Apr 30 11:55:32 wks104.hs.local PDF[1963] <Error>: FT_Load_Glyph failed: error 6.
Fri Apr 30 11:55:32 wks104.hs.local PDF[1963] <Error>: FT_Load_Glyph failed: error 6.
Fri Apr 30 11:55:32 wks104.hs.local PDF[1963] <Error>: FT_Load_Glyph failed: error 6.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
实际上,我通过修改上面的代码来创建多页 PDF,例如:
但是,如上所述,它忽略了我尝试设置的字体。我总是得到一些看起来像“Helvetica”的东西。
那么,目前没有办法在 iPad/iPhone 上创建嵌入设备上使用的字体的 PDF 文件吗?我简直不敢相信。我至少希望支持那些“常见的”字体,例如:Courier、Times New Roman 等。
如果有人有更多信息或有关解决方法的有用提示,欢迎分享。
提前致谢。
I actually got multi page PDF creation working by modifying the code above, like:
However, as mentioned above, it ignores the font I try to set. I always get something, looking like "Helvetica".
So, there is currently no way to create a PDF file on an iPad/iPhone, that embeds the font used on the device? I can hardly believe that. I would have at least hoped for those "usual suspects" fonts , like: Courier, Times New Roman, etc... to be supported.
If anyone out there has more information or useful tips on workarounds, please feel welcome to share.
Thanks in advance.
这是创建新 PDF 文档的方法。但它不进行文本格式化。
Here is a method that will create a new PDF document. It does not do text formatting though.
只是为了让您知道错误消息:
无效的 Type1 字体:无法流式传输字体
以及:
FT_Load_Glyph 失败:错误 6.
在 iOS 4.2 中消失
just to let you know that the error message:
invalid Type1 font: unable to stream font
and:
FT_Load_Glyph failed: error 6.
disappeared in iOS 4.2
这是一个更好的解决方案,因为它使用正确的坐标变换来使文本从上到下打印。
This is a better solution as it uses the correct coordinate transform to get the text to print from the top down.