title: How do I draw PDF NSData to a UIImage?
body: <p>I'm trying to basically understand how a simple PDF is created and turned into a UIImage on the iPhone. I have cobbled together this code:</p>
  
  <pre><code>NSMutableData *pdfData = [[NSMutableData alloc] init];
  UIGraphicsBeginPDFContextToData(pdfData, CGRectZero, nil);
  
  CFAttributedStringRef currentText = CFAttributedStringCreate(NULL, (CFStringRef)@"Text", NULL);
  CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString(currentText);
  UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, 612, 792), nil);
  CGMutablePathRef framePath = CGPathCreateMutable();
  CGPathAddRect(framePath, NULL, CGRectMake(0, 0, 612, 792));
  CTFrameRef frame = CTFramesetterCreateFrame(framesetter,
                                              CFRangeMake(0, [(NSString *)currentText length]),
                                              framePath,
                                              NULL);
  
  CTFrameDraw(frame, UIGraphicsGetCurrentContext());
  UIGraphicsEndPDFContext();
  UIImage *pdfImage = [UIImage imageWithData:pdfData]
  </code></pre>
  
  <p>I am fairly certain that this code is correct, aside from the last line (which is incorrect because UIImage cannot read PDF data), so I'm trying to find out which class I can send my PDF into.</p>
  
  <p>'pdfData' is not nil, it is about 5000 bytes in size.</p>
  
  <p>Any help you guys can give will be much appreciated. Cheers.</p>