title: drawInRect doesn't work with PDF
body: <p>I am updating an old app but I am not able to make drawInRect working on PDF context.</p>
  
  <p>I replaced the deprecated function CGContextShowTextAtPoint with CGContextShowTextAtPoint (see code below) but it doesn't write any text.</p>
  
  <p>Where am I wrong?</p>
  
  <p>This is my code:</p>
  
  <pre><code>-(NSMutableData *) writeToPDF {
  
  CGRect          pageRect;
  
  pageRect = CGRectMake(0.0f, 0.0f, 612, 850);
  
  NSMutableData *pdfData = [[NSMutableData alloc] init];
  CGDataConsumerRef dataConsumer = CGDataConsumerCreateWithCFData((CFMutableDataRef)pdfData);
  
  CGContextRef pdfContext = CGPDFContextCreate(dataConsumer, &amp;pageRect, NULL);
  
  CGContextSetTextDrawingMode (pdfContext, kCGTextFill);
  
  // Page 1
  
  CGContextBeginPage(pdfContext, &amp;pageRect);
  CGContextSetRGBStrokeColor(pdfContext, 0, 0, 0, 1);
  
  CGAffineTransform transf = CGAffineTransformMake(1, 0, 0, -1, 0, pageRect.size.height);
  CGContextConcatCTM(pdfContext, transf);
  
  // Line - OK
  
  CGContextMoveToPoint(pdfContext,0,0);
  CGContextAddLineToPoint(pdfContext,pageRect.size.width,pageRect.size.height);
  CGContextDrawPath(pdfContext, kCGPathStroke);
  
  CGContextSetTextDrawingMode (pdfContext, kCGTextFill);
  
  CGAffineTransform myTextTransform = CGAffineTransformMake(1,0,0,-1,0,0);
  CGContextSetTextMatrix(pdfContext, myTextTransform);
  
  // Text - Old working code to replace because CGContextSelectFont and CGContextShowTextAtPoint are deprecated
  
  CGContextSelectFont(pdfContext, "Helvetica", 20, kCGEncodingMacRoman);
  CGContextShowTextAtPoint(pdfContext, 50, 50, [@"Hello" UTF8String], [@"Hello" length]);
  
  // Text - Replacing code that doesn't work 
  
  NSDictionary *attrs = @{ NSForegroundColorAttributeName : [UIColor blackColor],
                           NSFontAttributeName : [UIFont systemFontOfSize:20]
                         };
  
  
  [@"Hello2" drawInRect:CGRectMake(50, 100, 100, 100) withAttributes:attrs];
  
  CGContextDrawPath(pdfContext, kCGPathStroke);
  
  CGContextEndPage(pdfContext);
  
  //
  
  CGPDFContextClose(pdfContext);
  CGContextRelease(pdfContext);
  
  CGDataConsumerRelease(dataConsumer);
  
  return pdfData;
  }
  </code></pre>