2013-12-12 124 views

回答

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; 
+0

如何NSMutableData轉換成的NSString?我被攻擊在這一點上?非常感謝 – Vara

+0

但是如何在webview中以pdf格式 – Vara

+0

顯示,例如 – thorb65