This used to work and now, all of a sudden, it stopped working:
For an iOS 7 iPad App, I generate a PDF with
UIGraphicsBeginPDFContextToFile(pdfPathWithFileName, CGRectZero, nil);
...
UIGraphicsEndPDFContext();
Within that code block, the following methods used to render text underlined, but recently, it just stopped working and any text passed to the method is not rendered at all:
+(void)drawUnderlinedText:(NSString *)text withFont:(UIFont *)font andColor:(UIColor *)color andLocationX:(int)locationX andLocationY:(int)locationY andTextAreaWidth:(int)textWidth andTextAreaHeight:(int)textHeight{
NSDictionary *attributesDict;
NSMutableAttributedString *attString;
attributesDict = @{NSForegroundColorAttributeName : color, NSFontAttributeName : font, NSUnderlineStyleAttributeName : [NSNumber numberWithInt:NSUnderlineStyleSingle]};
attString = [[NSMutableAttributedString alloc] initWithString:text attributes:attributesDict];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, color.CGColor);
CGRect rect = CGRectMake(locationX, locationY, textWidth, textHeight);
[attString drawInRect:rect];
}
I can't find anything on the web with regards to drawing to the PDF context. There are posts (and here) that mentions that issue with regards to labels. But there doesn't seem to be a solution for my problem when generating PDF files...
Please help!