First we implement this method:
- (UIPrintPaper *) printInteractionController:(UIPrintInteractionController *)printInteractionController choosePaper:(NSArray *)paperList {
Remember to reconcile the delegate in the .h file:
@interface yourViewController : UIViewController <UIPrintInteractionControllerDelegate>
You will receive a list of the exact paper sizes that your printer supports when you click the Print button on AirPrint. Check it out and see what rooms are available.
Then change the CGSize pageSize to one of the registered values. You'll find out if this works when the last NSLog βiOS says the best paper sizeβ now gives you the size of the dot you selected, instead of 4x6, the size of Letter or some other size that you don't need.
The reason you need to use size from the paper list is because the UIPrintPaper bestPaperForPageSize method does not seem to do what its name implies. One would think that, based on his name, he would process a close contribution and try to find something like that. However, it only returns the correct paper size when you give it an explicit match from the list of supported paper sizes.
My problem was that it would always be to choose a letter, no matter what size of the dot I would think working for 5x7. Actual dot sizes vary by region and printer.
Only after entering the matching numbers from the paper list can I print the PDF at 5x7.
Good luck
source share