Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a PDF programmatically on the iPhone?

Tags:

pdf

iphone

Hey all, was wondering if anyone could point me to the right direction. I'm curious about how I would go about creating a PDF programmatically on the iPhone. The documentation mentions CGPDFDocumentCreateWithProvider but i'm not sure how to go about using it. Thanks!


1 Answers

Likewise I do not believe it is possible to view a PDF on the iPhone without an external service to render the output

This is incorrect. You can render a PDF document within a UIWebView instance, for example:

NSString *urlPathStr = [[NSBundle mainBundle] pathForResource:@"myPDFFile" ofType:@"pdf"];
NSURL *url = [NSURL fileURLWithPath:urlPathStr];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
[myWebView loadRequest:urlRequest];

You can also render a PDF within a UIView object for better performance.

The PDFKit library is not yet available for the iPhone.

You might look at the QuartzDemo sample application for some Quartz2D methods for rendering and manipulating a PDF document.

like image 146
Alex Reynolds Avatar answered Sep 06 '26 04:09

Alex Reynolds



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!