Iphone 如何从pdf文件中的文件附件批注获取图像
我正在开发PDF注释应用程序我在iPhone中添加了PDF文件注释它工作正常it注释也可见任何读者但面临一个问题如何从PDF文件中的文件附件注释获取图像从桌面创建注释如何解决此问题 我正在使用这段代码从文件附件中获取注释的内容和位置,注释工作正常Iphone 如何从pdf文件中的文件附件批注获取图像,iphone,ios,objective-c,pdf,Iphone,Ios,Objective C,Pdf,我正在开发PDF注释应用程序我在iPhone中添加了PDF文件注释它工作正常it注释也可见任何读者但面临一个问题如何从PDF文件中的文件附件注释获取图像从桌面创建注释如何解决此问题 我正在使用这段代码从文件附件中获取注释的内容和位置,注释工作正常 CGPDFDictionaryRef pageDictionary = CGPDFPageGetDictionary(pPage); // NSLog(@"%@",(NSDictionary*)pageDictionary); CGPDF
CGPDFDictionaryRef pageDictionary = CGPDFPageGetDictionary(pPage);
// NSLog(@"%@",(NSDictionary*)pageDictionary);
CGPDFArrayRef outputArray;
if(!CGPDFDictionaryGetArray(pageDictionary, "Annots", &outputArray)) {
[pdfAnnots release];
return nil;
}
CGPDFArrayRef rectArray;
if(!CGPDFDictionaryGetArray(annotDict, "Rect", &rectArray)) {
break;
}
int arrayCount = CGPDFArrayGetCount( rectArray );
CGPDFReal coords[4];
for( int k = 0; k < arrayCount; ++k ) {
CGPDFObjectRef rectObj;
if(!CGPDFArrayGetObject(rectArray, k, &rectObj)) {
break;
}
CGPDFReal coord;
if(!CGPDFObjectGetValue(rectObj, kCGPDFObjectTypeReal, &coord)) {
break;
}
coords[k] = coord;
}
CGRect rect = CGRectMake(coords[0],coords[1],coords[2],coords[3]);
NSLog(@"%@",NSStringFromCGRect(rect));
请帮帮我
提前感谢终于得到解决方案了
CGPDFDictionaryRef aDict;
NSData *imagedata=nil;
if(CGPDFDictionaryGetDictionary(annotDict, "FS", &aDict))
{
CGPDFDictionaryRef embeddedFiles;
if (CGPDFDictionaryGetDictionary (aDict, "EF", &embeddedFiles) )
{
CGPDFStreamRef streamDict;
if (CGPDFDictionaryGetStream(embeddedFiles, "F", &streamDict))
{
CGPDFDataFormat *format = NULL;
CFDataRef xmlData;
xmlData = CGPDFStreamCopyData (streamDict, format);
imagedata=(NSData*)xmlData;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
savedImagePath = [documentsDirectory stringByAppendingPathComponent:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[(NSData*)xmlData writeToFile:savedImagePath atomically:NO];
}
}
}
CGPDFDictionaryRef aDict;
NSData *imagedata=nil;
if(CGPDFDictionaryGetDictionary(annotDict, "FS", &aDict))
{
CGPDFDictionaryRef embeddedFiles;
if (CGPDFDictionaryGetDictionary (aDict, "EF", &embeddedFiles) )
{
CGPDFStreamRef streamDict;
if (CGPDFDictionaryGetStream(embeddedFiles, "F", &streamDict))
{
CGPDFDataFormat *format = NULL;
CFDataRef xmlData;
xmlData = CGPDFStreamCopyData (streamDict, format);
imagedata=(NSData*)xmlData;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
savedImagePath = [documentsDirectory stringByAppendingPathComponent:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[(NSData*)xmlData writeToFile:savedImagePath atomically:NO];
}
}
}