Sending one page of a PDF file as an attachment from iPad using my own application

In my ios application, the user can send the PDF file as an application to another. It worked on pre ios 7 devices. After upgrading to ios 7, there was no attachment when the application was an ios mail interface.

Here is the i code used to set the mime type:

[mailComposer addAttachmentData:pdfData mimeType:@"application/octet-stream" fileName:fileName]; 

The above mime type works fine on pre ios 7, but on ios 7 it did not take my file as an attachment. So, I changed the mime type as follows:

 [mailComposer addAttachmentData:pdfData mimeType:@"application/pdf" fileName:fileName]; 

It worked great on ios 7 and pre ios 7, but the problem was that on the iPad, if the attached PDF file has one page, it is treated as an embedded image instead of an attachment. This only happens on the iPad on the iPhone. In addition, if I send this mail to someone, the recipient also displays as an inline image when they open this mail on the iphone or ipad. because when they click on it, it allows you to use two options 1. save the image 2. cancel. In addition, this problem does not apply to iOS 7 ipad devices, this happens on all ipad devices that work under ios 5, ios 6, ios 6.1 and ios 7. Any ideas how to resolve them? What type of mime should I use for this to solve this?

Note: - for more information, please check the attached screenshot enter image description here

-loganathan

+6
source share
3 answers

I have the same problem with a single page PDF. Just change mimeType to text / pdf instead of application / pdf and it works. No more changes needed.

 [objMailComposer addAttachmentData:myData mimeType:@"text/pdf" fileName:@"myapp.pdf"]; 
+5
source

Using the body of a regular text message, PDF will be displayed as a regular file attachment.

 [mailController setMessageBody:body isHTML:NO]; 
+2
source

I sometimes have the same problem with mail.app on OSX and compressed the file into a zip file as a workaround. Perhaps this is an option?

0
source

Source: https://habr.com/ru/post/954260/


All Articles