views:

15

answers:

1

Most, if not all, tutorials use CGPDFDocumentCreateWithURL(). What is the difference if using CGPDFDocumentCreateWithProvider() instead? Let's say the pdf is being taken from a local file on the device, not downloaded from some website. Will there be a performance difference? Which is better?

A: 

The most direct approach will be to use CGPDFDocumentCreateWithURL() with a file URL. To use CGPDFDocumentCreateWithProvider(), you will just have to create a provider from the file (or worse, read it all into an NSData, then wrap that in the provider), then create the document with the provider.

The only way to tell if there's a performance difference is to do both and then profile each for the workload you'll be applying them to.

Jeremy W. Sherman
Thanks. So, when is it more appropriate to use CGPDFDocumentCreateWithProvider()?
Altealice
When your code is already dealing with a provider for one reason or another, or you can't provide a URL for your data. For example, if you've built up a PDF document in memory, and you want to use that buffer to supply data to the CGPDFDocument, then you would wrap the buffer in a provider and use that to create the CGPDFDocument rather than writing the buffer to disk and then loading it from there.
Jeremy W. Sherman