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