iOS中有很多关于PDF的讨论,我在这里找到了我的问题的所有答案,除了一个:我有一个包含简单矢量形状的PDF文件。是否可以提取该形状的路径数据,以便我可以直接在Quartz图层上绘制形状?
到目前为止,我可以浏览PDF文档,生成如下输出:
Object key Resources type: kCGPDFObjectTypeDictionary
Object key ProcSet type: kCGPDFObjectTypeArray with length 4
Object key Array Object type: kCGPDFObjectTypeName PDF
Object key Array Object type: kCGPDFObjectTypeName ImageB
Object key Array Object type: kCGPDFObjectTypeName ImageC
Object key Array Object type: kCGPDFObjectTypeName ImageI
Object key ColorSpace type: kCGPDFObjectTypeDictionary
Object key Cs1 type: kCGPDFObjectTypeArray with length 2
Object key Array Object type: kCGPDFObjectTypeName ICCBased
Object key Array Object type: kCGPDFObjectTypeStream
Object key Length type: kCGPDFObjectTypeInteger 737
Object key N type: kCGPDFObjectTypeInteger 3
Object key Alternate type: kCGPDFObjectTypeName DeviceRGB
Object key Filter type: kCGPDFObjectTypeName FlateDecode
Object key XObject type: kCGPDFObjectTypeDictionary
Object key Im1 type: kCGPDFObjectTypeStream
Object key Length type: kCGPDFObjectTypeInteger 125
Object key Type type: kCGPDFObjectTypeName XObject
Object key Subtype type: kCGPDFObjectTypeName Image
Object key Width type: kCGPDFObjectTypeInteger 62
Object key Height type: kCGPDFObjectTypeInteger 49
Object key Interpolate type: kCGPDFObjectTypeBoolean 1
Object key ColorSpace type: kCGPDFObjectTypeArray with length 2
Object key Array Object type: kCGPDFObjectTypeName ICCBased
Object key Array Object type: kCGPDFObjectTypeStream
Object key Length type: kCGPDFObjectTypeInteger 737
Object key N type: kCGPDFObjectTypeInteger 3
Object key Alternate type: kCGPDFObjectTypeName DeviceRGB
Object key Filter type: kCGPDFObjectTypeName FlateDecode
Object key SMask type: kCGPDFObjectTypeStream
Object key Length type: kCGPDFObjectTypeInteger 36
Object key Type type: kCGPDFObjectTypeName XObject
Object key Subtype type: kCGPDFObjectTypeName Image
Object key Width type: kCGPDFObjectTypeInteger 62
Object key Height type: kCGPDFObjectTypeInteger 49
Object key ColorSpace type: kCGPDFObjectTypeName DeviceGray
Object key Interpolate type: kCGPDFObjectTypeBoolean 1
Object key BitsPerComponent type: kCGPDFObjectTypeInteger 8
Object key Filter type: kCGPDFObjectTypeName FlateDecode
Object key BitsPerComponent type: kCGPDFObjectTypeInteger 8
Object key Filter type: kCGPDFObjectTypeName FlateDecode
显然,有一个尺寸为62x49的图像和一个大小相同的面具(在形状周围,PDF是透明的)。图像绝对是矢量图形,我可以将其缩放到各种尺寸而不会丢失质量。那么frack是路径信息呢?
感谢您的任何信息!
最佳, 本杰明
答案 0 :(得分:0)
图像嵌入PDF文件本身。它没有路径 - 它不是外部文件。相反,它是PDF中的 stream 对象。您将需要解压缩(“膨胀”)该流对象(根据该XObject上的Filter值使用“flate”进行压缩),然后将其包含的PDF绘图/渲染命令解析并转换为等效的Quartz调用。这样做绝对是不琐碎 - 抱歉。 (我建议找一个能为你做这件事的图书馆。)
祝你好运!答案 1 :(得分:0)
GitHub上有一个小项目,它使用CGPDFScannerScan()来提取矢量数据:http://github.com/depth42/PWDynamicPDFImage