I\'m using following code to print HTML content containing text and images.
if (![UIPrintInteractionController isPrintingAvailable]) {
UIAlertView *alert
To specifically select A4 paper size, I implemented the printInteractionController:choosePaper:
method of the <UIPrintInteractionControllerDelegate>
protocol, and returned an A4 paper size if supported by the printer (test with [UIPrintPaper bestPaperForPageSize:withPapersFromArray:]
. Note that portrait/landscape orientation is not set here, but by the UIPrintInfo
property orientation
.
The property htmlFormatter.contentInsets
only sets the inset for the content as a whole, before it's been split across pages by the page renderer. I was able to set a 1cm per-page margin by adding blank headers and footers via a UIPrintPageRenderer
, and then adding a 1cm margin to the left and right of the HTML print formatter:
UIPrintPageRenderer *renderer = [[UIPrintPageRenderer alloc] init];
renderer.headerHeight = 30.0f;
renderer.footerHeight = 30.0f;
pic.printPageRenderer = renderer;
[renderer release];
UIMarkupTextPrintFormatter *htmlFormatter = [[UIMarkupTextPrintFormatter alloc] initWithMarkupText: htmlString];
htmlFormatter.startPage = 0;
htmlFormatter.contentInsets = UIEdgeInsetsMake(0.0f, 30.0f, 0.0f, 30.0f);
[renderer addPrintFormatter: htmlFormatter startingAtPageAtIndex: 0];
[htmlFormatter release];
Can't help with this one sorry.