Skip to content

Instantly share code, notes, and snippets.

@bigtunacan
Last active December 12, 2015 02:28
Show Gist options
  • Save bigtunacan/4698632 to your computer and use it in GitHub Desktop.
Save bigtunacan/4698632 to your computer and use it in GitHub Desktop.
Create a PDF from a webpage on iOS
- (NSString *)generatePDFFromWebView
{
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *pdfPath = [fileManager applicationSupportDirectory];
pdfPath = [pdfPath stringByAppendingPathComponent:@"exportedData.pdf"];
self.PDFCreator = [NDHTMLtoPDF createPDFWithURL:[NSURL URLWithString:@"www.cnn.com"]
pathForPDF:pdfPath
delegate:self
pageSize:kPaperSizeA4
margins:UIEdgeInsetsMake(10, 5, 10, 5)];
return pdfPath;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment