0

I have a UIWebView in my view controller. This UIWebView shows a PDF file. I have created a button. When the user clicks on this button, I want to send the content of the UIWebView via email. As a template I use the MailComposer from Apple. In this template Apple isn't using a UIWebView. Apple uses local stored data which works fine. So I am looking to send the content of the UIWebView, my displayed PDF, but I don't know how to do this.

Thanks.

Alexsander Akers
  • 15,967
  • 12
  • 58
  • 83
halloway4b
  • 573
  • 1
  • 11
  • 23

2 Answers2

0

You could try using -stringByEvaluatingJavaScriptFromString: to get the HTML content of the page and using -setMessageBody:isHTML: to set the message body. You may want use a <base /> tag, though, to set the page's base URL so relative URLs function.

Edit

You could download the PDF and use addAttachmentData:mimeType:fileName: to attach the PDF to an email.

Alexsander Akers
  • 15,967
  • 12
  • 58
  • 83
  • What would be the mimeType for pdf? application/pdf? And I got a warning at `picker.mailComposeDelegate = self;` Assigning to 'id' from incompatible type 'DetailViewController *const __strong' What could this be? – halloway4b Mar 02 '12 at 15:55
  • `application/pdf` is correct. The error you're receiving is due to your view controller class not conforming to the `MFMailComposeViewControllerDelegate` delegate protocol. – Alexsander Akers Mar 02 '12 at 21:31
  • How can I make my View Controller conform to this? – halloway4b Mar 03 '12 at 12:32
  • `@interface DetailViewController : UIViewController < MFMailComposeViewControllerDelegate>` – Alexsander Akers Mar 03 '12 at 23:34
0

What you will need to do is download the pdf and save it on the device and then attach it as per Apple' example.

see one approach to downloading here

Community
  • 1
  • 1
ader
  • 5,403
  • 1
  • 21
  • 26