Creating a PDF on iOS
Friday, February 17th, 2012I’m amazed at how easy it is to create a PDF on iOS. [cc] CGRect pageRect = CGRectMake(0, 0, 850, 1100); UIGraphicsBeginPDFContextToFile(outputFlePath, pageRect, nil); UIGraphicsBeginPDFPage(); CGContextRef pdfContext = UIGraphicsGetCurrentContext(); [self drawMyPageInContext:pdfContext]; UIGraphicsEndPDFContext(); [/cc] That’s it. You’ll have a PDF in the file identified by outputFilePath that has whatever you drew in the drawMyPageInContext method. Beautiful.