Skip to content

Instantly share code, notes, and snippets.

@samgreen
Created July 18, 2012 13:19
Show Gist options
  • Save samgreen/3136168 to your computer and use it in GitHub Desktop.
Save samgreen/3136168 to your computer and use it in GitHub Desktop.
- (void)createPDFFromContents {
NSString *pdfPath = [NSURL pathToDocuments:@"CostCalculator.pdf"];
BOOL success = UIGraphicsBeginPDFContextToFile(pdfPath, self.bounds, nil);
if (!success) return;
CGContextRef pdfContext = UIGraphicsGetCurrentContext();
UIGraphicsBeginPDFPage();
[self.layer renderInContext:pdfContext];
UIGraphicsEndPDFContext();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment