I create a pdf file in an ios application using the drawpdf function, calling the drawtext function in the nsobject class, it explicitly draws the text according to the frame and line that I specified.
My code
+(void)drawText:(NSString*)textToDraw inFrame:(CGRect)frameRect
{
CFStringRef stringRef = (__bridge CFStringRef)textToDraw;
CFAttributedStringRef currentText = CFAttributedStringCreate(NULL, stringRef, NULL);
CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString(currentText);
CGMutablePathRef framePath = CGPathCreateMutable();
CGPathAddRect(framePath, NULL, frameRect);
CFRange currentRange = CFRangeMake(0, 0);
CTFrameRef frameRef = CTFramesetterCreateFrame(framesetter, currentRange, framePath, NULL);
CGPathRelease(framePath);
CGContextRef currentContext = UIGraphicsGetCurrentContext();
CGContextSetTextMatrix(currentContext, CGAffineTransformIdentity);
CGContextTranslateCTM(currentContext, 0, frameRect.origin.y*2);
CGContextScaleCTM(currentContext, 1.0, -1.0);
CTFrameDraw(frameRef, currentContext);
CGContextScaleCTM(currentContext, 1.0, -1.0);
CGContextTranslateCTM(currentContext, 0, (-1)*frameRect.origin.y*2);
CFRelease(frameRef);
CFRelease(stringRef);
CFRelease(framesetter);
}
But I need to set the font of the font larger and bolder.
I used
CGContextSelectFont(currentContext, "Helvetica", 20, kCGEncodingMacRoman);
and
CGContextSetFontSize ( currentContext, 20);
with reference to the answer provided by mr.texian in the above function, but unchanged
I am showing the generated pdf file in uiwebview.
I got this code from the network. I did not know where to edit the code to customize the font. Any help would be appreciated.