Extracting images from a PDF

后端 未结 3 542
情深已故
情深已故 2020-12-12 18:43

I am having a little query regarding Extracting specifically images ( only images ) from a supplied PDF document in iPhone Application.

I have gone through the docum

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-12 19:13

    //it completely fit in view in uiview,pdf pages are get images in view
      CGPDFDocumentRef PDFfile;    
         CFURLRef pdfURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("iPhoneAppProgrammingGuide.pdf"), NULL, NULL);
                    PDFfile = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL);
                    CFRelease(pdfURL);
    
                CGPDFPageRef page = CGPDFDocumentGetPage(PDFfile,currentpage);
    
                context = UIGraphicsGetCurrentContext();
                CGContextSaveGState(context);
                CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0);
                CGContextFillRect(context,self.bounds);   
                CGContextTranslateCTM(context, -1.0, [self bounds].size.height);
                CGContextScaleCTM(context, 1.0, -1.0);
                CGContextConcatCTM(context, CGPDFPageGetDrawingTransform(page,  kCGPDFArtBox, [self bounds], 0, true));
                CGContextDrawPDFPage(context, page);    
                CGContextRestoreGState(context);
                CGAffineTransform transform = aspectFit(CGPDFPageGetBoxRect(page, kCGPDFMediaBox),
                                                            CGContextGetClipBoundingBox(context));
    
                   CGContextConcatCTM(context, transform);
                     UIGraphicsBeginImageContext(CGSizeMake(self.bounds.size.width, self.bounds.size.height));
    

提交回复
热议问题