以编程方式在iPhone上从HTML生成PDF [英] Programmatically Generate PDF from HTML on iPhone
问题描述
我正在寻找一种以编程方式(在obj-c中)从本地html文件生成PDF文件的方法。我从用户输入动态生成html,我需要创建PDF并将其发送给用户(通过电子邮件)。我对PDF生成部分有困难。
I am looking for a way to programmatically (in obj-c) generate a PDF file from a local html file. I am dynamically generating the html from user inputs, I need to create the PDF and send it to the user (via email). I am having difficulty with the PDF generation portion.
我有使用 CGPDFContextCreateWithURL
创建PDF的代码,但我我正在努力使用石英绘制页面。
I have the code to create a PDF using CGPDFContextCreateWithURL
but I am struggling with drawing the page using quartz.
我在SO以及互联网上广泛搜索无济于事。
I have searched extensively on SO as well as the internet to no avail.
非常感谢任何帮助!
推荐答案
生成pdf从HTML中,您需要将html呈现为Web视图,并拍摄Web视图的快照,并将它们渲染到图像上下文中。
本教程可能会有所帮助:
To generate a pdf from an HTML, you need to render the html into a web view, and take snapshots of the web view, and render them into an image context. The tutorial might be helpful:
http://www.ioslearner.com/convert-html-uiwebview-pdf-iphone-ipad/
这篇关于以编程方式在iPhone上从HTML生成PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!