如何在 Objective-C 中从图像生成 PDF? (在 Mac 操作系统上)
我正在尝试构建从 Objective-C 中的一堆图像生成单个 PDF 的代码。到目前为止,我看到的大多数示例都不允许我构建 PDF,而只是生成 Cocoa 视图并将它们转换为 PDF。
我正在寻找一些工具包(如 Java 的 iText),它允许我从一堆图像生成 PDF(每个图像都是 PDF 文档中的一个页面)。
有什么提示吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 PDFKit 更简单。
It's simpler with PDFKit.
请参阅创建 PDF 文件 部分。
有一个创建 pdf 文档的示例代码。您需要做的就是实现您的自定义
myDrawContent
函数,您可以在其中将图像绘制到 pdf 上下文,就像绘制任何其他 CGContextRef 一样。See Creating a PDF File section in Quartz 2D programming guide.
There's a sample code to create a pdf document. All you'll need to do there is implement your custom
myDrawContent
function, where you can draw your images to pdf context same way as to any other CGContextRef.