I am trying to create a pdf document with CGPDFContextCreateWithURL(). Everything seems ok from the code, but final pdf contains only rectangles and other graphics, but no text at all. The code is basically something like this:
When I open the resulting pdf file, it has only the red rectangle, but no text. I am still on SDK 2.2.1.
Code:
CGContextRef pdfContxt = CGPDFContextCreateWithURL ((CFURLRef)theUrl, &mediaBox, nil);
CGContextBeginPage (pdfContxt, NULL);
CGContextSaveGState (pdfContxt);
CGContextClipToRect (pdfContxt, mediaBox);
CGContextSetLineWidth (pdfContxt, 1.);
CGContextSetFillColorWithColor (pdfContxt, [UIColor blackColor].CGColor); // text color
CGContextSetStrokeColorWithColor (pdfContxt, [UIColor redColor].CGColor);
[@"Hello world!" drawInRect:textRect withFont:[UIFont italicSystemFontOfSize:24.] lineBreakMode:UILineBreakModeClip];
CGContextAddRect (pdfContxt, textRect);
CGContextDrawPath (pdfContxt, kCGPathStroke);
CGContextRestoreGState (pdfContxt);
CGContextEndPage (pdfContxt);
CGContextRelease (pdfContxt);
When I open the resulting pdf file, it has only the red rectangle, but no text. I am still on SDK 2.2.1.