I've got an iOS 6.1.3 App which puts together a bunch of attributed text (and optionally images) into a NSData using UIGraphicsBeginPDFContextToData. The data is then emailed with MFMailComposeViewController and
[picker addAttachmentData:pdfData mimeType:@"application/pdf" fileName:@"AppData.pdf"];
The PDF is sent and the resulting PDF opens fine in my Mac's "Preview" application. The PDFs will not, however open in Adobe Acrobat. If I drag the generated PDFs to Firefox, they open but with a warning. If drag them to Safari, I get the a warning "File does not begin with '%PDF-'". Looking a the PDF in BBEdit and "show invisibles", I see that there are indeed a large number of non-printing characters at the very start of the file, prior to the %PDF- If I remove those non-printing characters, the PDF does then open fine in Acrobat and Safari -- but the content of the PDF is not displayed, just a blank page.
The PDF creation I'm doing does involve adding encryption, though the problem is there even if no password is actually entered (i.e. the PDF is not actually encrypted). I also tried it without any encryption code (passing nil as the last parameter to UIGraphicsBeginPDFContextToData) but that made no difference.
Surely there must be a way to produce Adobe Acrobat compatible PDFs and email them from iOS?