Change the Document Title in PDF Metadata on iOS

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:

let pdfMetadata = PDFMetadata(document: document)

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

try? document.save()
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.

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.