- - (UIImage *)p_w_picpathFromPDFWithDocumentRef:(CGPDFDocumentRef)documentRef {
- CGPDFPageRef pageRef = CGPDFDocumentGetPage(documentRef, 1);
- CGRect pageRect = CGPDFPageGetBoxRect(pageRef, kCGPDFCropBox);
- UIGraphicsBeginImageContext(pageRect.size);
- CGContextRef context = UIGraphicsGetCurrentContext();
- CGContextTranslateCTM(context, CGRectGetMinX(pageRect),CGRectGetMaxY(pageRect));
- CGContextScaleCTM(context, 1, -1);
- CGContextTranslateCTM(context, -(pageRect.origin.x), -(pageRect.origin.y));
- CGContextDrawPDFPage(context, pageRef);
- UIImage *finalImage = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
- return finalImage;
- }
转载于:https://blog.51cto.com/rongbaohong/749717