How to get image from FileAttachment Annotation in pdf file

前端 未结 1 1361
臣服心动
臣服心动 2020-12-18 08:12

i am working on PDF annotation app i added PDF file annotation in iPhone it working fine it annotation also visible any reader but facing one issue How to get image from Fi

相关标签:
1条回答
  • 2020-12-18 08:50

    finally get solution

    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];
                }
            }
        }
    
    0 讨论(0)
提交回复
热议问题