Quelqu'un a-t-il essayé de lire le dictionnaire de catalogue d'un document PDF en utilisant les API de l'iPhone? Je n'obtiens rien de logique: la plupart des dictionnaires du catalogue sont vides.Problèmes de lecture de document PDF à l'aide du SDK iPhone?
1
A
Répondre
3
Essayez ceci:
CGPDFDictionaryRef catalog = CGPDFDocumentGetCatalog(myDocument);
CGPDFDictionaryApplyFunction(catalog, streamInfoFunction, catalog);
Le catalogue est essentiellement un dictionnaire et vous avez vous utilisez une fonction comme sur l'applicateur indiqué.
void streamInfoFunction (const char *key,CGPDFObjectRef object, void *info)
{
NSLog(@"---------------------------------------------------------------------------------------------");
NSLog(@"Processing Stream Info");
NSString *keyStr = [NSString stringWithCString:key encoding:NSUTF8StringEncoding];
CGPDFDictionaryRef contentDict = (CGPDFDictionaryRef)info;
CGPDFObjectType objectType = CGPDFObjectGetType(object);
if(objectType == kCGPDFObjectTypeDictionary)
{
CGPDFDictionaryRef value = NULL;
CGPDFDictionaryGetDictionary(contentDict, key, &value);
NSLog(@"Value for key %@ is %d",keyStr,CGPDFDictionaryGetCount(value));
//S.SNSLog(@"%@",value);
}
else if(objectType == kCGPDFObjectTypeArray)
{
CGPDFArrayRef value = NULL;
CGPDFDictionaryGetArray(contentDict, key, &value);
NSLog(@"Value for key %@ is %d",keyStr,CGPDFArrayGetCount(value));
//S.SNSLog(@"%@",value);
}
else if(objectType == kCGPDFObjectTypeStream)
{
CGPDFStreamRef value = NULL;
CGPDFDictionaryGetStream(contentDict, key, &value);
NSLog(@"Processing for key %@",keyStr);
CGPDFDataFormat dataFormat;
CFDataRef streamData = CGPDFStreamCopyData(value, &dataFormat);
CFShow(streamData);
NSString *contentString = [[NSString alloc]initWithBytes:[(NSData*)streamData bytes] length:[(NSData*)streamData length] encoding:NSUTF8StringEncoding];
NSLog(@"%@",contentString);
}
else if(objectType == kCGPDFObjectTypeInteger)
{
CGPDFInteger integerValue;
CGPDFDictionaryGetInteger(contentDict, key, &integerValue);
NSLog(@"Processing for Key %@ value %d",keyStr,integerValue);
}
else if(objectType == kCGPDFObjectTypeName)
{
const char *name;
CGPDFDictionaryGetName(contentDict, key, &name);
NSLog(@"Processing for key %@ value %s",keyStr,[NSString stringWithCString:name encoding:NSUTF8StringEncoding]);
}
NSLog(@"---------------------------------------------------------------------------------------------");
}
Pour une référence générale, voir: Fast and Lean PDF Viewer for iPhone/iPad/iOs - tips and hints?
Questions connexes
- 1. iphone créer un document pdf à partir de pages pdf
- 2. Lecture de PDF avec iphone
- 3. iPhone: Comment obtenir le titre d'un document PDF à partir du document?
- 4. Lecture de mp3 sur iphone sdk?
- 5. Lecture de fichiers MP3 avec iPhone SDK
- 6. Affichage d'un document PDF volumineux iPhone
- 7. Lecture audio à l'aide de l'iPhone SDK
- 8. iPhone SDK: Comment arrêter la lecture vidéo avec du code?
- 9. iPhone Simulator - Ecrire à des problèmes de fichiers/lecture
- 10. iphone pdf sauver le document magasin
- 11. Sélection de pages à partir du document PDF
- 12. Afficher grand PDF en utilisant SDK iPhone
- 13. iPhone SDK - Lecture audio/vidéo via UIWebView
- 14. Gestion du contenu PDF dans le kit SDK de l'iPhone?
- 15. Afficher les problèmes cachés dans iphone sdk
- 16. Problèmes de rendu PDF sur iPad
- 17. Problèmes de modification en mode UITableView (SDK iPhone)
- 18. Problème avec la lecture des données de plist iphone sdk
- 19. Open XML SDK 2.0 insertion de PDF à Word
- 20. Comment extraire le texte du document PDF
- 21. iPhone CatiledLayer pdf
- 22. iPhone SDK: Modifier la vitesse de lecture à l'aide de l'audio principal AVAudioPlayer
- 23. Diffuser de la vidéo à partir du serveur. {iPhone SDK}
- 24. TouchXML: Problèmes de lecture d'informations EDSP avec Iphone
- 25. iPhone SDK Zoom et actualisation PDF avec Quartz
- 26. Obtenir document PDF aperçu
- 27. naviguer vers un numéro de page spécifique du document pdf
- 28. Extraction de texte d'un document PDF - C#
- 29. iPhone SDK: crash de pushViewController
- 30. Problèmes de caractères parasites lors de la lecture du fichier