In fact, I created a multi-page PDF creation by changing the code above, for example:
- (void) createPDF:(NSString *)fileName withContent:(NSString *)content forSize:(int)fontSize andFont:(NSString *)font andColor:(UIColor *)color { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *newFilePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:fileName]; CGRect a4Page = CGRectMake(0, 0, DOC_WIDTH, DOC_HEIGHT); NSDictionary *fileMetaData = [[NSDictionary alloc] init]; if (!UIGraphicsBeginPDFContextToFile(newFilePath, a4Page, fileMetaData )) { NSLog(@"error creating PDF context"); return; } BOOL done = NO; CGContextRef context = UIGraphicsGetCurrentContext(); CFRange currentRange = CFRangeMake(0, 0); CGContextSetTextDrawingMode (context, kCGTextFill); CGContextSelectFont (context, [font cStringUsingEncoding:NSUTF8StringEncoding], fontSize, kCGEncodingMacRoman); CGContextSetFillColorWithColor(context, [color CGColor]);
However, as mentioned above, it ignores the font I'm trying to install. I always get something like "Helvetica".
So, there is currently no way to create a PDF file on an iPad / iPhone that includes the font used on the device? I can hardly believe it. I would at least hope for these βregular suspectβ fonts such as Courier, Times New Roman, etc., to be supported.
If anyone has additional information or helpful hints for workarounds, please share it.
Thanks in advance.
Friendlydeveloper
source share