【发布时间】:2014-12-20 14:06:37
【问题描述】:
我做了一些研究,发现我应该能够将 PDF 转换为 byte[],然后转换为 UIImage,但到目前为止还没有运气。无法使用 CoreGraphics 的原因是我使用的是不支持 CGPDF 类的 apportable。
我能够创建一个似乎包含 PDF 的 NSData 对象,但是当使用该对象创建 UIImage 时,图像为零。
- (instancetype) initWithBackSize: (CGSize) size
{
NSString *path = [[ NSBundle mainBundle ] pathForResource:@"pdfTest.pdf" ofType:nil ];
NSData* pdfData = [NSData dataWithContentsOfFile:path];
UIImage* image = [[UIImage alloc] initWithData:pdfData];
CCTexture* texture = [[CCTexture alloc] initWithCGImage: image.CGImage contentScale: image.scale];
self = [super initWithTexture: texture];
return self;
}
【问题讨论】:
标签: ios objective-c pdf uiimage apportable