我想生成一个UIScrollView的pdf,其内容大小接近320*2000左右.如果我使用当前图形图像上下文来捕获滚动视图图层,那么它只捕获滚动视图的可见部分而不是该滚动视图的整个图层.
我使用以下代码:
-(void)CreatePdf:(id)sender
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *saveDirectory = [paths objectAtIndex:0];
NSString *saveFileName = @"myPDF.pdf";
[self writePDFAma];
CGRect arect=CGRectMake(0, 0, 768, 1024);
CreatePDFFileAma(arect, nil);
}
-(void) writePDFAma
{
UIImage *image;
NSData *data;
UIAlertView *successAlert;
UIAlertView *failureAlert;
//
NSArray *documentPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
// // This should be our documents directory
NSString *saveDiirectory = [documentPath objectAtIndex:0];
// // Our PDF is named 'Example.pdf'
NSString *saveFileName = @"FormImage2.JPG";
// // Create the full path using our saveDirectory …Run Code Online (Sandbox Code Playgroud)