The entire point of this question was text as text and not screenshot
The following answer shows how to make a bitmap screenshot, in a pdf container...
#import
- (NSString *)pdfPath {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"tmp.pdf"];
return writableDBPath;
}
- (NSDictionary *)pdfContextDictionary {
NSDictionary *d = [NSDictionary dictionaryWithObjectsAndKeys:@"J. P. Author", kCGPDFContextAuthor,
@"My Cool App", kCGPDFContextCreator,
@"This is the Output", kCGPDFContextTitle,
nil];
return d;
}
- (void)printToPDF {
NSString *path = [self pdfPath];
UIView *displayView = self.view;
CGRect pageRect = displayView.bounds;
if (UIGraphicsBeginPDFContextToFile(path, pageRect, [self pdfContextDictionary]) == NO) {
return; // error
}
UIGraphicsBeginPDFPage();
CGContextRef context = UIGraphicsGetCurrentContext();
CALayer *layer = displayView.layer;
[layer renderInContext:context];
UIGraphicsEndPDFContext();
NSLog(@"[%@ %@] %@", NSStringFromClass([self class]), NSStringFromSelector(_cmd), path);
}