私はしばらくの間、PDFパッケージに含まれているpdfドキュメントを解凍できるように努力してきました。どこにもドキュメンテーションやサンプルコードは見つかりませんでしたが、Adobe ReaderアプリとPDFExpertアプリでサポートされているため不可能ではありません。私がそれはそれに付属していません願って、彼らは自分のパーサを持っている可能性があり...PDF iOSのパッケージ
正しい方向に私を指すようになります任意のヒントを大幅に
編集を理解されるであろう。長い時間の後私はこれに取り組んで、ついにそれを理解しました。 正しい方向に私を向けるiPDFDevに特別なおかげで!
ここで、各インナーCGPDFDocumentRef取得する方法上のコードです:私はあなたがPDFポートフォリオを参照してくださいと仮定PDFパッケージで
NSURL *url = [NSURL fileURLWithPath:filePath isDirectory:NO];
CGPDFDocumentRef pdf = CGPDFDocumentCreateWithURL((__bridge CFURLRef)url);
CGPDFDictionaryRef catalog = CGPDFDocumentGetCatalog(pdf);
CGPDFDictionaryRef names = NULL;
if (CGPDFDictionaryGetDictionary(catalog, "Names", &names)) {
CGPDFDictionaryRef embFiles = NULL;
if (CGPDFDictionaryGetDictionary(names, "EmbeddedFiles", &embFiles)) {
// At this point you know this is a Package/Portfolio
CGPDFArrayRef nameArray = NULL;
CGPDFDictionaryGetArray(embFiles, "Names", &nameArray);
// nameArray contains the inner documents
// it brings the name and then a dictionary from where you can extract the pdf
for (int i = 0; i < CGPDFArrayGetCount(nameArray); i+=2) {
CGPDFStringRef name = NULL;
CGPDFDictionaryRef dict = NULL;
if (CGPDFArrayGetString(nameArray, i, &name) &&
CGPDFArrayGetDictionary(nameArray, i+1, &dict)) {
NSString *_name = [self convertPDFString:name];
CGPDFDictionaryRef EF;
if (CGPDFDictionaryGetDictionary(dict, "EF", &EF)) {
CGPDFStreamRef F;
if (CGPDFDictionaryGetStream(EF, "F", &F)) {
CFDataRef data = CGPDFStreamCopyData(F, NULL);
CGDataProviderRef provider = CGDataProviderCreateWithCFData(data);
CGPDFDocumentRef _doc = CGPDFDocumentCreateWithProvider(provider);
if (_doc) {
// save the docRef somewhere (_doc)
// save the pdf name somewhere (_name)
}
CFRelease(data);
CGDataProviderRelease(provider);
}
}
}
}
}
}
- (NSString *)convertPDFString:(CGPDFStringRef)string {
CFStringRef cfString = CGPDFStringCopyTextString(string);
NSString *result = [[NSString alloc] initWithString:(__bridge NSString *)cfString];
CFRelease(cfString);
return result;
}
これまでに動作させましたか?私はあまりにも苦労しています... – JMIT
ええ、それは私が使用したコードです。私はCGPDF APIがまだ動作していると仮定します – Ismael