我有两个UIView
s 需要转换为 PDF 并作为附件发送。我下面的代码与第一个重叠UIView
。我想将此作为电子邮件的附件发送。
谢谢你。
NSMutableData *pdfData=[NSMutableData data];
UIGraphicsBeginPDFContextToData(pdfData,aView.bounds, nil);
CGContextRef pdfContext=UIGraphicsGetCurrentContext();
UIGraphicsBeginPDFPage();
[aView.layer renderInContext:pdfContext];
UIGraphicsEndPDFContext();
UIGraphicsBeginPDFContextToData(pdfData, bView.bounds, nil);
CGContextRef pdfContext2=UIGraphicsGetCurrentContext();
UIGraphicsBeginPDFPage();
[bView.layer renderInContext:pdfContext2];
UIGraphicsEndPDFContext();
MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
mailer.mailComposeDelegate = self;
NSString *subject=[NSString stringWithFormat:@"Delivery Report-%@",[globUserID uppercaseString]];
[mailer setSubject:subject];
[mailer addAttachmentData:pdfData mimeType:@"pdf" fileName:@"DeliveryReport.pdf"];
[self presentModalViewController:mailer animated:YES];