Get CGPDFDocumentRef name of document

帅比萌擦擦* 提交于 2019-12-21 05:08:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!