Reputation: 2217
I tried to get a PDFDocument from a WebView but I only got a part of the Page :-(
The code I used is this:
//Generate a PDF document from the HTML.
NSData *pdfData = [webView dataWithPDFInsideRect:[webView frame]];
PDFDocument *document = [[PDFDocument alloc] initWithData:pdfData];
[document writeToURL:[NSURL URLWithString:@"file:///Users/tmp/test.pdf"]];
Any idea how to make it better?
Upvotes: 2
Views: 1512
Reputation: 5230
NSData *pdfData = [[[[webview mainFrame] frameView] documentView] dataWithPDFInsideRect:[[[webview mainFrame] frameView] documentView].frame];
PDFDocument *document = [[PDFDocument alloc] initWithData:pdfData];
[document writeToFile:@"/Users/PalmAgent/Desktop/test.pdf"];
Upvotes: 4
Reputation: 96323
Upvotes: 3