title: UIPrintPageRenderer not drawing anything with UIMarkupTextPrintFormatter
body: <p>My first time dealing with this technology.</p>
  
  <p>Essentially I got a core data database of data I wish to generated table out of.</p>
  
  <p>I have found this post here:</p>
  
  <p><a href="https://stackoverflow.com/questions/9528658/is-there-any-way-to-generate-pdf-file-from-a-xml-html-template-in-ios">Is there any way to generate PDF file from a XML/HTML template in iOs</a></p>
  
  <p>but I am stumbling on trying to get something visible out of the generated PDF.</p>
  
  <p>So far, I have only managed to get the PDF to show 2 blank white pages, it doesn't print my simple text.</p>
  
  <p>Here's my class file:</p>
  
  <pre><code>// PageRenderer Class header file
  #import &lt;UIKit/UIKit.h&gt;
  
  @interface PageRenderer : UIPrintPageRenderer
  {
      BOOL _generatingPdf;
  }
  
  -(CGRect) paperRect;
  -(CGRect) printableRect;
  -(NSData*) printToPDF;
  
  @end
  
  
  
  // PageRenderer Class implementation file
  #import "PageRenderer.h"
  
  @implementation PageRenderer
  
  - (CGRect) paperRect
  {     
      if (!_generatingPdf)
      {
          return [super paperRect];
      }
  
      return UIGraphicsGetPDFContextBounds();
  }
  
  - (CGRect) printableRect
  {
      if (!_generatingPdf)
          return [super printableRect];
  
      return CGRectInset( self.paperRect, 20, 20 );
  }
  
  - (NSData*) printToPDF
  {
      _generatingPdf = YES;
  
      NSMutableData *pdfData = [NSMutableData data];
  
      UIGraphicsBeginPDFContextToData( pdfData, CGRectMake(0, 0, 792, 612), nil );  // letter-size, landscape
  
      [self prepareForDrawingPages: NSMakeRange(0, 1)];
  
      CGRect bounds = UIGraphicsGetPDFContextBounds();
  
      for ( int i = 0 ; i &lt; self.numberOfPages ; i++ )
      {
          UIGraphicsBeginPDFPage();
  
          [self drawPageAtIndex: i inRect: bounds];
      }
  
      UIGraphicsEndPDFContext();
  
      _generatingPdf = NO;
  
      //    NSString* filename = @"/Volumes/Macintosh HD 2/test.pdf";
      //    [pdfData writeToFile: filename  atomically: YES];
  
      return pdfData;
  }
  
  - (NSInteger)numberOfPages
  {
      return 1;
  }
  
  @end
  </code></pre>
  
  <p>Here is my code where I am generating the PDF file:</p>
  
  <pre><code>-(void)generateLog
  {        
      UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController];
  
      pic.delegate = self;
  
      PageRenderer *pageRenderer = [[PageRenderer alloc] init];
  
      pic.printPageRenderer = pageRenderer;
  
      UIMarkupTextPrintFormatter *html = [[UIMarkupTextPrintFormatter alloc] init];
      //html.markupText = @"&lt;table border='1' width='500' height='200'&gt;";
      html.markupText = @"&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;p&gt;HTML TEXT HERE, &lt;b&gt;BOLD&lt;/b&gt; THIS!&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;";
      html.startPage = 0;
      html.contentInsets = UIEdgeInsetsMake(72.0, 72.0, 72.0, 72.0); // 1 inch margins
      html.maximumContentWidth = 6 * 72.0;
  
      pic.printFormatter = html;
  
      [pageRenderer drawPrintFormatter:html forPageAtIndex:0];    
  
      NSData *pdfData = [pageRenderer printToPDF];
  
      [pdfData writeToFile:[MediaDirectory mediaPathForFileName:@"triplog.pdf"] atomically:YES];
  
      NSLog(@"triplog.pdf written to %@", [MediaDirectory mediaPathForFileName:@"triplog.pdf"]);
  
      [html release];
  }
  </code></pre>
  
  <p>Any ideas why I am getting a blank page?</p>