Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -(void)printButtonTapped:(CGRect)rect
- {
- if ([UIPrintInteractionController isPrintingAvailable] == YES)
- {
- // NSURL *fileURL = document.fileURL; // Document file URL
- NSString* str=[NSString stringWithFormat:@"%@/Documents/mypdf.pdf",NSHomeDirectory()];
- NSURL* url=[NSURL URLWithString:str];
- if ([UIPrintInteractionController canPrintURL:url] == YES)
- {
- self.printInteraction = [UIPrintInteractionController sharedPrintController];
- UIPrintInfo *printInfo = [UIPrintInfo printInfo];
- printInfo.duplex = UIPrintInfoDuplexLongEdge;
- printInfo.outputType = UIPrintInfoOutputGeneral;
- printInfo.jobName = [url lastPathComponent];;
- self.printInteraction.printInfo = printInfo;
- self.printInteraction.printingItem = url;
- self.printInteraction.showsPageRange = YES;
- if ([[UIDevice currentDevice]userInterfaceIdiom] == UIUserInterfaceIdiomPad) // Large device printing
- {
- [self.printInteraction presentFromRect:rect inView:self.view animated:YES completionHandler:
- ^(UIPrintInteractionController *pic, BOOL completed, NSError *error)
- {
- #ifdef DEBUG
- if ((completed == NO) && (error != nil)) NSLog(@"%s %@", __FUNCTION__, error);
- #endif
- }
- ];
- }
- else // Handle printing on small device
- {
- [self.printInteraction presentAnimated:YES completionHandler:
- ^(UIPrintInteractionController *pic, BOOL completed, NSError *error)
- {
- #ifdef DEBUG
- if ((completed == NO) && (error != nil)) NSLog(@"%s %@", __FUNCTION__, error);
- #endif
- }
- ];
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement