2011-05-21 39 views

回答

0

首先将当前视图保存为具有这种功能的图像:

How can i create a PDF file programmatically in an iphone application?

- (void)saveScreenshot:(NSArray*)arguments withDict:(NSDictionary*)options 
{ 
CGRect screenRect = [[UIScreen mainScreen] bounds]; 
CGRect imageRect = CGRectMake(0, 0, CGRectGetWidth(screenRect), CGRectGetHeight(screenRect)); 
UIGraphicsBeginImageContext(imageRect.size); 

CGContextRef ctx = UIGraphicsGetCurrentContext(); 
[[UIColor blackColor] set]; 
CGContextTranslateCTM(ctx, 0, 0); 
CGContextFillRect(ctx, imageRect); 

[webView.layer renderInContext:ctx]; 

UIImage *image1 = UIGraphicsGetImageFromCurrentImageContext(); 
UIImageWriteToSavedPhotosAlbum(image1, nil, nil, nil); 
UIGraphicsEndImageContext(); 

// alert to let us know success. remove this later. 
UIAlertView *alert= [[UIAlertView alloc] initWithTitle:nil message:@"Image Saved" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
[alert show]; 
[alert release]; 
} 

接着通过在这个问题的StackOverflow以下的方向上的图像转换为PDF