title: How to print on half page or A5 using AirPrint?
body: <p>I have an app that needs to print receipts and passes from the iPad. I have implemented the AirPrint SDK which is working fine, i.e., I am able to print documents from the iPad using an AirPrint compatible printer.</p>
  
  <p>The issue is I need these receipts and passes to be on half a page (half of an A4 page that is) or an A5 page. No matter what changes I make to the print job, it always prints in the full A4 page and in landscape.</p>
  
  <p>Here's my code to print:</p>
  
  <pre><code>UIPrintInteractionController *printer = [UIPrintInteractionController sharedPrintController];
  UIPrintInfo *printObject = [UIPrintInfo printInfo];
  [printObject setJobName:@"Receipt"];
  [printObject setOutputType:UIPrintInfoOutputGeneral];
  [printObject setOrientation:UIPrintInfoOrientationLandscape];
  
  UIPrintFormatter *printFormatter = [[UIPrintFormatter alloc] init];
  [printFormatter setContentInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
  
  [printer setPrintFormatter:printFormatter];
  [printer setPrintInfo:printObject];
  [printer setDelegate:self];
  [printer setPrintingItem:targetURL];
  [printer presentFromRect:sender inView:view animated:YES completionHandler:^(UIPrintInteractionController *printInteractionController,BOOL completed, NSError *error){}];
  </code></pre>
  
  <p>I also tried implementing the <code>choosePaper</code> delegate method but it didn't help either. Oh and while creating the document, I specify the size:</p>
  
  <pre><code>CGSize pageSize = CGSizeMake(595, 420);
  NSString* fileName = @"GatePass.PDF";
  
  NSArray *arrayPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  NSString *path = [arrayPaths objectAtIndex:0];
  NSString* pdfFileName = [path stringByAppendingPathComponent:fileName];
  
  UIGraphicsBeginPDFContextToFile(pdfFileName, CGRectZero, nil);
  
  UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, pageSize.width, pageSize.height), nil);
  </code></pre>
  
  <p>The way it should ideally work is that if the user uses A5 paper in a print, print normally. If the user uses A4 paper, print in just half the page and so on.</p>
  
  <p>Any idea how this can be achieved?</p>