Issues with email attachment, PDF and CSV

我是研究僧i 提交于 2019-12-20 03:01:14

问题


I'm working with PDF generation,it generated the PDF, viewed using QLPreviewController, all worked fine except mail forwarding, I have two attachments of type .pdf and .csv. I have the following issues while emailing.

  • sometimes no attachments while emailing
  • pdf size will be very huge when pdf contains image(10 mb for one page pdf, if it contains image)

    Problem is when testing in device,in simulator it all works fine..., I come to know some exporting or importing UTI associated issues here since I am a starter I feel difficult to understand it, I think some UTI's I have to add somewhere.. Can anyone please help me to identify the issue and solve, please. Thanks in advance.


回答1:


1. Attachment issue

set mime type as text/csv instead of application/csv or image/csv. code is as shown below

[mailComposer addAttachmentData:[NSData dataWithContentsOfFile:self.csvFilePath]
                               mimeType:@"text/csv" fileName:[NSString stringWithFormat:@"csvPage.csv" ]];

1. Size issue

I struggled a lot.. at last when wrote image in jpeg format to pdf page using below code, size got reduced ten times!!

UIImage *lowResImage = [UIImage imageWithData:UIImageJPEGRepresentation(plotImage, 0.02)];


来源:https://stackoverflow.com/questions/15173941/issues-with-email-attachment-pdf-and-csv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!