Changing the Document Title

By default, PSPDFKit parses a document and extracts the PDF title from the PDF metadata. If there is no metadata or the PDF name is Untitled, then it’ll fall back to the file name and remove the .pdf filetype.

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

The document title can be customized using PSPDFDocumentPDFMetadata, like this:

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

By default, PSPDFKit 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.