Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create a PDF file programmatically in an iOS application?

Tags:

ios

pdf

How to generate a PDF file on a user action?

like image 418
raaz Avatar asked Sep 01 '09 06:09

raaz


People also ask

How do I create a PDF from a Web application?

To create a PDF from the currently open web page, choose Convert Web Page To PDF. Then select a location, type a filename, and click Save. To add a PDF of the currently open web page to another PDF, choose Add Web Page To Existing PDF. Then locate and select the existing PDF, and click Save.

Does iOS have a PDF editor?

Edit a PDF in the Books app on your iPhone or iPad If you want to edit or add a signature to a PDF, use Markup. To rename a PDF on your iPhone, open the Books app and find the PDF in the Library tab. To find the PDF on your iPad, go to Library in the sidebar. Then tap the Show Actions button and choose Rename.


2 Answers

See "Drawing with Quartz" to see how to create a PDF Graphics Context.

Some notes:

"iPhoneOSNote: If you want to create a PDF graphics context in an iPhone application, make sure you also read “Drawing to a Graphics Context in iPhone OS” (page 27)."

"You can write any content to a PDF that’s appropriate for your application—images, text, path drawing—and you can add links and encryption. For more information see “PDF Document Creation, Viewing, and Transforming” (page 177)."

like image 65
mahboudz Avatar answered Oct 21 '22 06:10

mahboudz


As an example of creating a PDF from the contents of a CALayer, you can refer to the -dataForPDFRepresentationOfLayer method within the CPLayer class in the Core Plot framework. You can do something similar to extract the content from a CALayer-backed UIView, although we had to subclass CALayer in order to get vector elements to render to a PDF properly.

like image 32
Brad Larson Avatar answered Oct 21 '22 04:10

Brad Larson