5

Trying to print an html page containing a table usingUIMarkupTextPrintFormatter. For some strange reason, the last row gets pushed to the second page when there is plenty of space (2-3inches) left on the first page. Even worse, when I remove the last row from the html table, the now last row, which is a couple inches longer than the deleted one, is split between page 1 and 2 when it clearly fit on page 1 before deleting the row. Header and Footer height are both set to zero. Insets also zero. The same html fits perfectly on 1 page when using a UIWebView and printing using UIViewPrintFormatter *formatter = [webview viewPrintFormatter]; But this requires to show the UIWebView (so it gets rendered) and I don't want to do this.

Any insight to this is greatly appreciated.

ED.
  • 231
  • 2
  • 4

1 Answers1

0

In a similar situation, but with a fixed size of my html table this worked for me:

    formatter.maximumContentWidth = 10. * 72.;

might be not the most elegant solution, you would have to adjust the parameters (i.e. make them dynamic) and check the paper size dependence:

    UIPrintFormatter *formatter = [[UIMarkupTextPrintFormatter alloc] initWithMarkupText:html];
    formatter.startPage = 0;
    formatter.contentInsets = UIEdgeInsetsMake(36., 14., 0., 0.);

    // prevent to generate an extra blank page
    formatter.maximumContentWidth = 10. * 72.;

    ...
    [formatter release];
    // please note        
    printInfo.orientation = UIPrintInfoOrientationLandscape;
pirx
  • 1
  • 3