I would like to attach pdf created as an email attachment. I used following tutorial to create pdf on iOS device.
The downloaded pdf can be viewed at this path: /Users/”Username”/Library/Application Support/iPhone Simulator/”Your App Directory”.
I have not tried running this on ios device but I need to attach it as an email.
Link for tutorial is : http://www.ioslearner.com/generate-pdf-programmatically-iphoneipad/
Any suggestion.
See the docs for
MFMailComposeViewController
. Specifically, you're looking for theaddAttachmentData:mimeType:fileName:
method. That should get you going.Create a
MFMailComposeViewController
and calladdAttachmentData:mimeType:fileName:
. The data will be the PDF you created. The mimeType will beapplication/pdf
. And the fileName will be the name of the file in the email attachment. The code might look like something below:From the tutorial you'll need to render your PDF into a NSMutableData object:
Then at some point in the future you'll need to pass that pdfData to the
MFMailComposeViewController
.