PDFViewController.m 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. //
  2. // PDFViewController.m
  3. // RedAnt ERP Mobile
  4. //
  5. // Created by Ray on 14-8-7.
  6. // Copyright (c) 2014年 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "PDFViewController.h"
  9. #import "RAUtils.h"
  10. #import "const.h"
  11. #import "AppDelegate.h"
  12. @interface PDFViewController ()
  13. @end
  14. @implementation PDFViewController
  15. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  16. {
  17. self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  18. if (self) {
  19. // Custom initialization
  20. }
  21. return self;
  22. }
  23. - (void)viewDidLoad
  24. {
  25. [super viewDidLoad];
  26. // Do any additional setup after loading the view.
  27. UIRefreshControl *ref = [[UIRefreshControl alloc]init];
  28. ref.tag = 200 ;
  29. ref.attributedTitle = [[NSAttributedString alloc]initWithString:@"drag to refresh"];
  30. ref.tintColor = [UIColor colorWithRed:0.10 green:0.68 blue:0.94 alpha:0.7];
  31. // ref.hidden = true;
  32. [ref addTarget:self action:@selector(changeCell) forControlEvents:UIControlEventValueChanged];
  33. [self.webView.scrollView addSubview:ref];
  34. self.webView.dataDetectorTypes=UIDataDetectorTypeAll;
  35. UIBarButtonItem *closeButton = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"back"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
  36. style:UIBarButtonItemStylePlain
  37. target:self
  38. action:@selector( onBackClick:)];
  39. //[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Close", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onCloseClick:)];
  40. // closeButton.title = @"Close";
  41. self.navigationItem.leftBarButtonItem = closeButton;
  42. self.btnshare = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"share"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
  43. style:UIBarButtonItemStylePlain
  44. target:self
  45. action:@selector(onActionClick:)];//[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Edit", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onOpenOrderClick:)];
  46. // self.btnshare.tintColor = UIColorFromRGB(0x996633);
  47. self.btnemail =[[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"mail"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
  48. style:UIBarButtonItemStylePlain
  49. target:self
  50. action:@selector(onEmailClick:)];// [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Commit", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onCommitOrderClick:)];
  51. // self.btnemail.tintColor = UIColorFromRGB(0x996633);
  52. // self.btnSend = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Email", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onSendMailClick:)];
  53. self.btnsave = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"save"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
  54. style:UIBarButtonItemStylePlain
  55. target:self
  56. action:@selector(onSaveClick:)];
  57. // self.btnsave.tintColor = UIColorFromRGB(0x996633);
  58. UIBarButtonItem *fixedItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
  59. fixedItem.width = 20.0f;
  60. NSMutableArray * items = [[NSMutableArray alloc]init];
  61. [items addObject:self.btnshare];
  62. [items addObject:fixedItem];
  63. [items addObject:self.btnemail];
  64. if(self.canSave)
  65. {
  66. [items addObject:fixedItem];
  67. [items addObject:self.btnsave];
  68. }
  69. self.navigationItem.rightBarButtonItems=items;
  70. self.btnshare.enabled =false;
  71. self.btnemail.enabled =false;
  72. self.btnsave.enabled =false;
  73. // self.url=@"http://192.168.1.3:8080/npd/test.pdf";
  74. // NSURL* url = [NSURL URLWithString:self.url];
  75. //
  76. // NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:self.url] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:2000];
  77. //
  78. //
  79. // [self.webView loadRequest:request];
  80. [self loadcontent];
  81. }
  82. - (void)onBackClick:(UIButton *)sender {
  83. [self.navigationController popViewControllerAnimated:FALSE];
  84. }
  85. -(void)ReloadData
  86. {
  87. // Count ++ ;
  88. // [mytabelview reloadData];
  89. UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
  90. [reF endRefreshing];
  91. [self loadcontent];
  92. }
  93. -(void) loadcontent
  94. {
  95. UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Loading..."];
  96. self.mum.hidden=false;
  97. if(self.isLocalfile)
  98. {
  99. self.content= [NSData dataWithContentsOfFile:self.url];
  100. [self.webView loadData:self.content MIMEType:@"application/pdf" textEncodingName:nil baseURL:nil];
  101. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  102. self.filename=[self.url lastPathComponent];
  103. self.btnshare.enabled =true;
  104. self.btnemail.enabled =true;
  105. self.btnsave.enabled =true;
  106. if(self.onLoadSuccess)
  107. self.onLoadSuccess(self.url);
  108. if(self.autoPrint)
  109. [self startAirPrintWithData:self.content];
  110. }
  111. else
  112. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  113. NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:self.url] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60*5];
  114. //设置请求方式为get
  115. [request setHTTPMethod:@"GET"];
  116. //添加用户会话id
  117. [request addValue:@"text/html" forHTTPHeaderField:@"Content-Type"];
  118. //连接发送请求
  119. NSHTTPURLResponse* urlResponse = nil;
  120. NSError *error = nil;
  121. self.content= [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];
  122. self.filename = [urlResponse suggestedFilename];
  123. dispatch_async(dispatch_get_main_queue(), ^{
  124. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  125. [[self navigationController] setNavigationBarHidden:self.hidenavi animated:NO];
  126. self.navigationItem.title = self.save_name;
  127. UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
  128. // self.content=nil;
  129. if(self.content!=nil&&self.content.length>0)
  130. {
  131. [reF removeFromSuperview];
  132. // NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  133. NSString *path = NSTemporaryDirectory();
  134. NSString *filePath = [path stringByAppendingPathComponent:self.filename];
  135. // NSError *error = nil;
  136. // BOOL bo = [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&error];
  137. // NSAssert(bo,@"创建目录失败");
  138. [self.content writeToFile:filePath atomically:YES];
  139. self.btnshare.enabled =true;
  140. self.btnemail.enabled =true;
  141. self.btnsave.enabled =true;
  142. if(self.onLoadSuccess)
  143. self.onLoadSuccess(self.url);
  144. if(self.autoPrint)
  145. [self startAirPrintWithData:self.content];
  146. // int a=0;
  147. }
  148. else
  149. {
  150. [RAUtils message_alert:nil title:@"Open PDF Failed" controller:self];
  151. if(self.autoPrint)
  152. [self.navigationController popViewControllerAnimated:true];
  153. // self.content = [self.url dataUsingEncoding:NSUTF8StringEncoding];
  154. }
  155. ;
  156. // NSLog(@"%@",[[NSString alloc] initWithData:self.content encoding:NSASCIIStringEncoding]);
  157. //
  158. NSLog(urlResponse.MIMEType);
  159. [self.webView loadData:self.content MIMEType:urlResponse.MIMEType textEncodingName:nil baseURL:nil];
  160. });
  161. });
  162. }
  163. -(void)changeCell
  164. {
  165. UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
  166. reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"refreshing"];
  167. if ([self respondsToSelector:@selector(ReloadData)])
  168. [self performSelector:@selector(ReloadData) withObject:nil afterDelay:1];
  169. // DebugLog(@"refresh!!!!!!!!");
  170. }
  171. - (void)didReceiveMemoryWarning
  172. {
  173. [super didReceiveMemoryWarning];
  174. // Dispose of any resources that can be recreated.
  175. }
  176. -(void) viewWillAppear:(BOOL)animated
  177. {
  178. [super viewWillAppear:animated];
  179. [[self navigationController] setNavigationBarHidden:self.hidenavi animated:NO];
  180. }
  181. - (IBAction)onActionClick:(id)sender {
  182. //NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  183. NSString *path = NSTemporaryDirectory();
  184. NSString* filename =self.filename;
  185. NSString *filePath = [path stringByAppendingPathComponent:filename];
  186. [self openFile:filePath];
  187. }
  188. - (IBAction)onSaveClick:(id)sender {
  189. //UIAlertControllerStyle两种类型UIAlertControllerStyleAlert类似UIAlertView
  190. //UIAlertControllerStyleActionSheet类似UIActionSheet
  191. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Save pdf" message:nil preferredStyle:UIAlertControllerStyleAlert];
  192. //block代码块取代了delegate
  193. [alertControl addTextFieldWithConfigurationHandler:^(UITextField *textField) {
  194. textField.text = self.save_name;
  195. }];
  196. UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Save" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  197. UITextField *name = alertControl.textFields.firstObject;
  198. if(name.text.length==0)
  199. {
  200. [RAUtils message_alert:@"Cannot save without name. Save canceled." title:@"Name is missing" controller:self];
  201. }
  202. else
  203. {
  204. self.save_name = name.text;
  205. self.btnsave.enabled =false;
  206. // NSMutableDictionary * info =
  207. if(self.onSavePDF)
  208. self.onSavePDF(self.save_name,self.filename);
  209. }
  210. }];
  211. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  212. NSLog(@"Cancel");
  213. }];
  214. [alertControl addAction:actionOne];
  215. [alertControl addAction:alertthree];
  216. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  217. [self presentViewController:alertControl animated:YES completion:nil];
  218. }
  219. - (IBAction)onEmailClick:(id)sender {
  220. //NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  221. NSString *path = NSTemporaryDirectory();
  222. NSString* filename =self.filename;
  223. NSString *filePath = [path stringByAppendingPathComponent:filename];
  224. MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
  225. if(mc==nil)
  226. {
  227. //[RAUtils message_alert:@"You must create an email account first." title:@"Send Email" controller:self];
  228. return;
  229. }
  230. mc.mailComposeDelegate = self;
  231. [mc setSubject:self.mail_subject];
  232. [mc setToRecipients:self.mail_to];
  233. if(self.mail_content==nil)
  234. self.mail_content=@"";
  235. NSString* htmlbody = [NSString stringWithFormat:@"<html><p>%@</p></html>",self.mail_content];
  236. [mc setMessageBody:htmlbody
  237. isHTML:YES];
  238. NSData *data = [NSData dataWithContentsOfFile:filePath];
  239. if(self.attachment_name.length>0)
  240. filename = self.attachment_name;
  241. [mc addAttachmentData:data mimeType:@"application/pdf" fileName:filename];
  242. [self presentModalViewController:mc animated:YES];
  243. return;
  244. }
  245. -(void)openFile: (NSString *) file_url {
  246. NSURL *file_URL = [NSURL fileURLWithPath:file_url];
  247. if (file_URL != nil) {
  248. if (self.fileInteractionController == nil) {
  249. //_fileInteractionController = [[UIDocumentInteractionController alloc] init];
  250. _fileInteractionController = [UIDocumentInteractionController interactionControllerWithURL:file_URL];
  251. _fileInteractionController.delegate = self;
  252. // [_fileInteractionController retain];//不适用ARC,记得RETAIN 使用ARC注释这一行
  253. }
  254. else
  255. {
  256. self.fileInteractionController.URL = file_URL;
  257. }
  258. // [self.fileInteractionController presentOpenInMenuFromRect:self.view.frame inView:self.view animated:YES];
  259. [self.fileInteractionController setName:self.mail_subject];
  260. // [self.fileInteractionController setAnnotation:<#(id _Nullable)#>;
  261. [self.fileInteractionController presentOptionsMenuFromBarButtonItem:self.btnshare animated:YES];
  262. // [self.fileInteractionController presentOptionsMenuFromRect:self.view.frame inView:self.view animated:YES];
  263. // [self.fileInteractionController presentPreviewAnimated:YES];
  264. }
  265. }
  266. //- (void) sendEmail:(NSString *)to cc:(NSString*)cc subject:(NSString*)subject body:(NSString*)body
  267. //{
  268. // NSString* str = [NSString stringWithFormat:@"mailto:%@?cc=%@&subject=%@&body=%@",
  269. // to, cc, subject, body];
  270. // str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  271. //
  272. // [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
  273. //
  274. //
  275. //}
  276. #pragma mark methods for the UIDocumentInteractionControllerDelegate
  277. - (void)documentInteractionControllerDidDismissOptionsMenu:(UIDocumentInteractionController *)controller
  278. {
  279. // if (controller == self.fileInteractionController) {
  280. // self.fileInteractionController = nil;
  281. // }
  282. }
  283. - (void)previewDocumentWithURL:(NSURL*)url
  284. {
  285. UIDocumentInteractionController* preview = [UIDocumentInteractionController interactionControllerWithURL:url];
  286. preview.delegate = self;
  287. [preview presentPreviewAnimated:YES];
  288. }
  289. - (void)documentInteractionControllerDidEndPreview:(UIDocumentInteractionController *)controller
  290. {
  291. }
  292. - (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller{
  293. return self;
  294. }
  295. - (CGRect)documentInteractionControllerRectForPreview:(UIDocumentInteractionController *)controller{
  296. return self.view.frame;
  297. }
  298. - (UIView *)documentInteractionControllerViewForPreview:(UIDocumentInteractionController *)controller{
  299. return self.view;
  300. }
  301. - (void)documentInteractionController:(UIDocumentInteractionController *)controller willBeginSendingToApplication:(nullable NSString *)application // bundle ID
  302. {
  303. }
  304. #pragma mark - web view delegate
  305. - (void)webViewDidFinishLoad:(UIWebView *)webView
  306. {
  307. self.mum.hidden=true;
  308. }
  309. #pragma mark -MFMailComposeViewControllerDelegate delegate
  310. - (void)mailComposeController:(MFMailComposeViewController*)controller
  311. didFinishWithResult:(MFMailComposeResult)result
  312. error:(NSError*)error {
  313. switch (result)
  314. {
  315. case MFMailComposeResultCancelled:
  316. NSLog(@"Mail send canceled...");
  317. break;
  318. case MFMailComposeResultSaved:
  319. NSLog(@"Mail saved...");
  320. break;
  321. case MFMailComposeResultSent:
  322. NSLog(@"Mail sent...");
  323. break;
  324. case MFMailComposeResultFailed:
  325. NSLog(@"Mail send errored: %@...", [error localizedDescription]);
  326. break;
  327. default:
  328. break;
  329. }
  330. [self dismissModalViewControllerAnimated:YES];
  331. }
  332. /*
  333. #pragma mark - Navigation
  334. In a storyboard-based application, you will often want to do a little preparation before navigation
  335. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
  336. {
  337. Get the new view controller using [segue destinationViewController].
  338. Pass the selected object to the new view controller.
  339. }
  340. */
  341. - (void)startAirPrintWithData:(id )data
  342. {
  343. UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"preparing print..."];
  344. UIPrintInteractionController* airPrinterController=[UIPrintInteractionController sharedPrintController];
  345. UIPrintInfo *printInfo = [UIPrintInfo printInfo];
  346. printInfo.outputType = UIPrintInfoOutputGeneral;
  347. printInfo.orientation = UIPrintInfoOrientationPortrait;
  348. printInfo.jobName = @"CoolVisitAirPrint";
  349. airPrinterController.printInfo = printInfo;
  350. airPrinterController.printingItem = data;
  351. airPrinterController.delegate = self;
  352. airPrinterController.showsNumberOfCopies=true;
  353. airPrinterController.showsPageRange = true;
  354. airPrinterController.showsPaperSelectionForLoadedPapers=true;
  355. void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = ^(UIPrintInteractionController *printController, BOOL completed, NSError *error) {
  356. if(completed && error)
  357. NSLog(@"Printing failed due to error in domain %@ with error code %lu. Localized description: %@, and failure reason: %@", error.domain, (long)error.code, error.localizedDescription, error.localizedFailureReason);
  358. };
  359. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  360. UIPrinter *airPrinter = [UIPrinter printerWithURL:[NSURL URLWithString:appDelegate.printerURL] ];///*self.printer;*/
  361. [[UIPrinter printerWithURL:[NSURL URLWithString:appDelegate.printerURL]] contactPrinter:^(BOOL available)
  362. {
  363. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  364. if (available&& appDelegate.printerURL.length>0)
  365. {
  366. [airPrinterController printToPrinter:airPrinter completionHandler:completionHandler];
  367. NSLog(@"AIRPRINTER AVAILABLE");
  368. }
  369. else
  370. {
  371. // [airPrinterController presentFromRect:CGRectMake(0, 0, 300, 500) inView:self.view animated:YES completionHandler:
  372. //
  373. //
  374. //
  375. // // [printPicker presentAnimated:YES completionHandler:
  376. // ^(UIPrintInteractionController *printerController, BOOL userDidSelect, NSError *error)
  377. // {
  378. // if (userDidSelect)
  379. // {
  380. // NSString* sid= printerController.printInfo.printerID;
  381. // UIPrintPaper*paper= printerController.printPaper;
  382. //
  383. // }
  384. // }];
  385. NSLog(@"AIRPRINTER NOT AVAILABLE");
  386. if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1)
  387. {
  388. UIPrinterPickerController *printPicker = [UIPrinterPickerController printerPickerControllerWithInitiallySelectedPrinter:nil];
  389. // [printPicker presentFromBarButtonItem:self.btnSubmitOrder animated:yes completionHandler:
  390. [ printPicker presentFromBarButtonItem:self.btnshare animated:YES completionHandler:
  391. // [printPicker presentFromRect:CGRectMake(0, 0, 300, 500) inView:self.view animated:YES completionHandler:
  392. // [printPicker presentAnimated:YES completionHandler:
  393. ^(UIPrinterPickerController *printerPicker, BOOL userDidSelect, NSError *error)
  394. {
  395. if (userDidSelect)
  396. {
  397. //User selected the item in the UIPrinterPickerController and got the printer details.
  398. [UIPrinterPickerController printerPickerControllerWithInitiallySelectedPrinter:printerPicker.selectedPrinter];
  399. //Here you will get the printer and printer details.ie,
  400. // printerPicker.selectedPrinter, printerPicker.selectedPrinter.displayName, printerPicker.selectedPrinter.URL etc. So you can display the printer name in your label text or button title.
  401. appDelegate.printerURL =printerPicker.selectedPrinter.URL.absoluteString;
  402. [self startAirPrintWithData:data];
  403. }
  404. else
  405. {
  406. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  407. // if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
  408. // {
  409. //
  410. // [((MainViewController*)appDelegate.main_vc) Loginout:false];
  411. // }
  412. // [self prepareReturn:nil];
  413. //[self.navigationController popViewControllerAnimated:true];
  414. }
  415. }];
  416. }
  417. }
  418. }];
  419. }
  420. #pragma mark - UIPrintInteractionControllerDelegate
  421. - (UIPrintPaper *)printInteractionController:(UIPrintInteractionController *)printInteractionController choosePaper:(NSArray<UIPrintPaper *> *)paperList
  422. {
  423. ;
  424. // (int) width = 29700
  425. // Printing description of (*( (int *)0x7caa3a40)):
  426. // (int) height = 42000
  427. //设置纸张大小
  428. for(UIPrintPaper* paper in paperList)
  429. {
  430. if (CGSizeEqualToSize(paper.paperSize, CGSizeMake(612, 792)))
  431. return paper;
  432. }
  433. CGSize paperSize = CGSizeMake(612, 792);
  434. UIPrintPaper * p=[UIPrintPaper bestPaperForPageSize:paperSize withPapersFromArray:paperList];
  435. return p;
  436. }
  437. - (void)printInteractionControllerWillPresentPrinterOptions:(UIPrintInteractionController *)printInteractionController
  438. {
  439. }
  440. - (void)printInteractionControllerDidPresentPrinterOptions:(UIPrintInteractionController *)printInteractionController
  441. {
  442. }
  443. - (void)printInteractionControllerWillDismissPrinterOptions:(UIPrintInteractionController *)printInteractionController
  444. {
  445. }
  446. - (void)printInteractionControllerDidDismissPrinterOptions:(UIPrintInteractionController *)printInteractionController
  447. {
  448. }
  449. - (void)printInteractionControllerWillStartJob:(UIPrintInteractionController *)printInteractionController
  450. {
  451. }
  452. - (void)printInteractionControllerDidFinishJob:(UIPrintInteractionController *)printInteractionController
  453. {
  454. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  455. // if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
  456. // {
  457. //
  458. // [((MainViewController*)appDelegate.main_vc) Loginout:false];
  459. // }
  460. //
  461. // [self prepareReturn:nil];
  462. if(self.autoPrint)
  463. [self.navigationController popViewControllerAnimated:true];
  464. }
  465. @end