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 PDFMetadata and XMPMetadata 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 PDFMetadata, like this:

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

let metadataKey = PDFMetadata.Key.title
let metadataValue = "New Document Title"
pdfMetadata?.setObject(metadataValue, forInfoDictionaryKey: metadataKey)

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

PSPDFMetadataName metadataKey = PSPDFMetadataTitleKey;
NSString *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 false in PDFConfiguration. Set this to false to manually configure the title, or set the title in the document to something custom.

Hiding the Overlaid Document Title

To hide the title shown in a box with a black transparent background just below the top navigation bar, set documentLabelEnabled to .NO in PDFConfiguration.