I attached a file to the mail I am using this code.
[mail addAttachmentData:[myView PDFData] mimeType:@\"application/pdf\" fileName:@\"name.pdf\"];
Full code to print pdf
UIPrintInteractionController *pc = [UIPrintInteractionController
sharedPrintController];
UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputGeneral;
printInfo.orientation = UIPrintInfoOrientationPortrait;
printInfo.jobName =@"Report";
pc.printInfo = printInfo;
pc.showsPageRange = YES;
pc.printingItem = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"https://test.com/Print_for_Client_Name.pdf"]];
// You can use here image or any data type to print.
UIPrintInteractionCompletionHandler completionHandler =
^(UIPrintInteractionController *printController, BOOL completed,
NSError *error) {
if(!completed && error){
NSLog(@"Print failed - domain: %@ error code %ld", error.domain,
(long)error.code);
}
};
[pc presentFromRect:CGRectMake(0, 0, 300, 300) inView:self.view animated:YES completionHandler:completionHandler];