Reputation: 185
Im trying to print to a label printer from an ios app. The size of the labels are 39mm x 39mm.
I have tried all four methods for printing and none print to the correct dimensions of the label.
I believe the root cause is that ios only supplies a range of UIPrintPaper options from which you can choose and none match what I need.
I cannot find a way to specify a custom UIPrintPaper or printableRect which can be used for printing.
Any ideas stackoverflow people?
Upvotes: 1
Views: 1054
Reputation: 518
I recently had to solve a similar problem with printing a barcode in a UIWebView to a roll of 28.9mm x 62mm address labels. The content was printing with a bunch of excess whitespace at the bottom - which was a waste of labels. So I implemented a method that UIPrintInteractionControllerDelegate provides for specifying at what length the paper should be cut.
Assuming your label paper is 39mm wide, you can just worry about the length and implement this method to always cut the paper length at 39mm (I believe the float value it should return is based on 72 points per inch - I ended up using 90.0 to handle the 28.9mm tall die-cut labels):
- (CGFloat)printInteractionController:(UIPrintInteractionController *)printInteractionController cutLengthForPaper:(UIPrintPaper *)paper;
Upvotes: 1