小编use*_*309的帖子

从UIScrollView + iphone生成PDF

我想生成一个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)

pdf iphone scrollview cgcontext

3
推荐指数
2
解决办法
4269
查看次数

标签 统计

cgcontext ×1

iphone ×1

pdf ×1

scrollview ×1