Change the Document Title

PSPDFKit by default parses the document and extracts the PDF title from the PDF metadata. If there is no metadata or the PDF name equals "Untitled", then it'll fall back to the file name, just removing the .pdf filetype.

PSPDFKit exposes PSPDFDocumentPDFMetadata and PSPDFDocumentXMPMetadata to work with the PDF metadata. You can learn more about using and customizing metadata here.

The document title can be customized using PSPDFDocumentPDFMetadata like that:

Copy
1
2
3
4
5
6
7
let pdfMetadata = PSPDFDocumentPDFMetadata(document: document)

let metadataKey = "Title"
let metadataValue = ["NewDocumentTitle"]
pdfMetadata.setObject(metadataValue, forInfoDictionaryKey: metadataKey)

try? document.save()
Copy
1
2
3
4
5
6
7
PSPDFDocumentPDFMetadata *pdfMetadata = [[PSPDFDocumentPDFMetadata alloc] initWithDocument:document];

NSString *metadataKey = @"Title";
NSArray *metadataValue = @[@"NewDocumentTitle"];
[pdfMetadata setObject:metadataValue forKeyedSubscript:metadataKey];

[document saveWithOptions:nil error:NULL];

You can learn more about PDF metadata in the PDF Reference 1.7, Table 317:

Navigation Bar Changes

PSPDFKit by default sets the title of the navigation bar to the document title, unless allowToolbarTitleChange is set to NO in PSPDFConfiguration. Set this to NO to manually configure the title, or set the title in the document to something custom.