问题
Is it possible to retrieve the name of a document from a CGPDFDocumentRef
回答1:
By "name of a document", do you mean the document filename or title?
If the document "title" is included in the metadata it can be retrieved like this:
char *titleKey = "Title";
CGPDFStringRef titleStringRef;
CGPDFDictionaryRef info = CGPDFDocumentGetInfo(myDocumentRef);
CGPDFDictionaryGetString(info, titleKey, &titleStringRef);
const unsigned char *titleCstring = CGPDFStringGetBytePtr(titleStringRef);
printf("title: %s", titleCstring);
The other keys are listed in section 10.2 of the PDF 1.7 specification: Adobe PDF Reference Archives
来源:https://stackoverflow.com/questions/5881921/get-cgpdfdocumentref-name-of-document