我正在成功显示文字,但如何在pdf文件中显示图片?
其实我是pdf转换的新手
提前致谢。
答案 0 :(得分:1)
我这样做,我的基本图像在NSData对象中:
NSMutableData *pdfData = [NSMutableData data];
UIGraphicsBeginPDFContextToData(pdfData, CGRectMake(0, 0, 2480, 3508), nil);
UIImage *aImg = [UIImage imageWithData:myImageData];
UIGraphicsBeginPDFPage();
NSData *jpegData = UIImageJPEGRepresentation(aImg, 0.5);
CGDataProviderRef dp = CGDataProviderCreateWithCFData((__bridge CFDataRef)jpegData);
CGImageRef cgImage = CGImageCreateWithJPEGDataProvider(dp, NULL, true, kCGRenderingIntentDefault);
[[UIImage imageWithCGImage:cgImage] drawInRect:CGRectMake(0, 0, aImg.size.width, aImg.size.height)];
UIGraphicsEndPDFContext();
return pdfData;