UIMarkupTextPrintFormatter printing extra blank page

ios, printing

Solution

I solved it by having the correct HTML skeleton:

NSString *htmlString = "<!DOCTYPE html><html><head><meta charset='UTF-8'><title>Title</title></head><body>Hello!</body></html>"

Problem

When using UIMarkupTextPrintFormatter to print a few lines of simple HTML, it puts out a blank page first, then the page with the text. The code is as follows, and very simple: ``` - (void) printSomething; { if (![UIPrintInteractionController isPrintingAvailable]) return; NSString* markupText =@"<html><body>THIS IS A TEST</body></html>"; UIMarkupTextPrintFormatter* printFormatter =[ [ [UIMarkupTextPrintFormatter alloc] initWithMarkupText:markupText] autorelease]; UIPrintInteractionController* printInteractionController =[UIPrintInteractionController sharedPrintController]; printInteractionController.printFormatter =printFormatter; printInteractionController.delegate =self; //printInteractionController.showsPageRange =YES; [printInteractionController presentAnimated:YES completionHandler:nil]; } ``` Now, if I uncomment the showsPageRange =YES, a single page prints as expected, BUT the UIPrintInteractionController takes several seconds to appear. Enough to make the user wonder if the app froze. The very first line of the UIMarkupTextPrintFormatter docs state "Instances of the UIMarkupTextPrintFormatter class lay out HTML markup text for a multipage print job". It'd be kinda crazy if the formatter prints multiple pages, regardless of content... Any idea what's wrong here? Other apps do this without any issues. Thanks in advance.

Original source