I’m using code to create a PDF File. Works.
But: I want my whole UITableView(I need to scroll) in my PDF File and not just the part of the view which is currently displayed on screen.
Is there a way to achieve this?
Thanks a lot.
CODE:
NSString * newFilePath = [[self documentPath] stringByAppendingPathComponent:@"Auswertung.pdf"];
CGRect page = self.view.frame;
NSDictionary * metaData = nil;
if (!UIGraphicsBeginPDFContextToFile(newFilePath, page, metaData )) {
NSLog(@"error creating PDF context");
return;
}
UIGraphicsBeginPDFPage();
[self.tableView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIGraphicsEndPDFContext();
It’s not as easy as that. UITableView reuses it’s cell, so a simple draw on the whole view would possibly only show some cells that are currently visible in the viewport. You need to manually use the cells and draw them one after reach other. Shouldn’t be too hard if you just use the dataSource. Be careful, this may lead to memory problem if the cell is very large.