I am developing an application which needs to send an email with attachment, I want to create that attachment as PDF file from Text(NSString) and images(NSData) to a single NSData object and preparing PDF file and preparing mail with PDF file as attachment. but if I send mail and open that attachment in system that PDF file is not opening. if I try to open that downloaded attachment as normal PDF file, it is saying "file may be damaged or use a file format that Preview doesn’t recognize". the following is my piece of code
NSMutableData *emailImageData = [NSMutableData dataWithData:scGetImgData([[tempArray objectAtIndex:0] UTF8String])];
NSString *afterImgStr = [tempArray objectAtIndex:1];
NSData *stringData = [afterImgStr dataUsingEncoding:NSUTF8StringEncoding];
[pdfArticle appendData:emailImageData];
[pdfArticle appendData:stringData];
UIGraphicsBeginPDFContextToData(pdfArticle, CGRectZero,nil);
UIGraphicsBeginPDFPage();
[mail addAttachmentData:pdfArticle mimeType:@"application/pdf" fileName:@"Article.pdf"];
someone please help, some help will be useful to me.
Thanks in advance.