【问题标题】:Converting PDF to UIImage, without CoreGraphic's PDF Classes将 PDF 转换为 UIImage,无需 CoreGraphic 的 PDF 类
【发布时间】: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


    【解决方案1】:

    PDF 文件中的二进制数据不能直接转换为 UIImage 类型。您需要找到第三方库或其他将 PDF 文件转换为 UIImage 的方法。

    【讨论】:

      猜你喜欢
      • 2015-12-12
      • 1970-01-01
      • 2018-05-22
      • 2016-03-17
      • 1970-01-01
      • 2016-10-30
      • 1970-01-01
      • 2016-06-15
      • 1970-01-01
      相关资源
      最近更新 更多