【发布时间】:2012-02-18 04:03:26
【问题描述】:
我正在尝试将 ThumbnailImage 创建为 Word 文档。我使用 UIWebView 加载文档,然后将其转换为图像。 PNG。我看了一千遍,文件路径是正确的,但最终的图像是空白的。有人可以看看我的代码,看看是否有问题?非常感谢您。
UIWebView *myWebView22 = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
path44 = [caminoINICIAL stringByAppendingPathComponent:@"documentoInicial.doc"];
NSURL *fileURL22 = [[NSURL alloc] initFileURLWithPath:path44];
NSURLRequest *req22 = [NSURLRequest requestWithURL:fileURL22];
[myWebView22 setScalesPageToFit:YES];
[myWebView22 loadRequest:req22];
UIGraphicsBeginImageContext(myWebView22.bounds.size);
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(c, 0, 0);
[myWebView22.layer renderInContext:c];
UIImage* viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
pngPath = [caminoINICIAL stringByAppendingPathComponent:[NSString stringWithFormat:@"imagenFinal.png"]];
[UIImagePNGRepresentation(viewImage) writeToFile:pngPath atomically:YES];
【问题讨论】:
标签: objective-c ios thumbnails