I am trying to modify the PDF metadata (title, author, etc.) of an existing PDF on iOS. While it is easy to find sample code for PDF parsing and for PDF creation from scratch, there does not seem to be an easy way to dump an existing PDF into a new file - and modify it just slightly.
More specifically, how do I get the info obtained when reading a PDF roughly like this:
CGPDFDocumentRef myPDF = CGPDFDocumentCreateWithURL((CFURLRef)urlOfInputPDF);
CGPDFDictionaryRef myPDFDict=CGPDFDocumentGetInfo(myPDF);
into the new PDF, which I would create roughly this way:
CGRect pageRect;
CFMutableDictionaryRef myDictionary = CFDictionaryCreateMutable(NULL, 0,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
CFDictionarySetValue(myDictionary, kCGPDFContextTitle, CFSTR("My PDF File"));
CFDictionarySetValue(myDictionary, kCGPDFContextCreator, CFSTR("My Name"));
pdfContext = CGPDFContextCreateWithURL (urlOfOutputPDF, &pageRect, myDictionary);
Obviously, the dictionary types do not match, and the output created this way is page (not document) related.
Any ideas, how I can copy the whole CGPDFDocumentRef into a new file? And how to make it mutable, so I can modify the meta data before saving?