本文共 695 字,大约阅读时间需要 2 分钟。
- - (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