@steipete, @all Hi, I tried the code below, it generates a multi-page PDF file, but the visible area in the field of view is repeated for all pages. add more ideas to improve the result.
-(void)createPDFfromUIView:(UIWebView*)aView saveToDocumentsWithFileName:(NSString*)aFilename { NSString *oldFilePath= [[NSBundle mainBundle] pathForResource:@"ABC" ofType:@"pdf"]; NSMutableData *pdfData = [NSMutableData data]; UIGraphicsBeginPDFContextToData(pdfData, aView.bounds, nil); CFURLRef url = CFURLCreateWithFileSystemPath (NULL, (CFStringRef)oldFilePath, kCFURLPOSIXPathStyle, 0); CGPDFDocumentRef templateDocument = CGPDFDocumentCreateWithURL(url); CFRelease(url); size_t count = CGPDFDocumentGetNumberOfPages(templateDocument); for (size_t pageNumber = 1; pageNumber <= count; pageNumber++) { UIGraphicsBeginPDFPage(); CGContextRef pdfContext = UIGraphicsGetCurrentContext(); [aView.layer renderInContext:pdfContext]; } CGPDFDocumentRelease(templateDocument);
source share