---
title: "Editing PDF metadata with Nutrient Python SDK | Nutrient Python SDK"
canonical_url: "https://www.nutrient.io/guides/python/editor/editing-pdf-metadata/"
md_url: "https://www.nutrient.io/guides/python/editor/editing-pdf-metadata.md"
last_updated: "2026-06-09T10:32:42.848Z"
description: "How to edit PDF metadata using Nutrient Python SDK."
---

# Editing PDF metadata with Nutrient Python SDK

PDF metadata — title, author, creation date, and custom properties — is crucial for document management, search functionality, and compliance. Being able to programmatically edit this metadata enables organizations to standardize document properties across large repositories and maintain consistent, searchable records.

[Download sample](https://www.nutrient.io/downloads/samples/python/editing-pdf-metadata.zip)

## How Nutrient helps you achieve this

Nutrient Python SDK handles PDF metadata manipulation. With the SDK, you don’t need to worry about:

- Parsing PDF internal structures

- Managing XMP schemas

- Handling metadata encoding

- Complex XML manipulation

Instead, Nutrient provides an API that handles all the complexity behind the scenes, letting you focus on your business logic.

## Complete implementation

Below is a complete working example that demonstrates editing PDF metadata. These lines set up the Python application. The import statements bring in all necessary classes from the Nutrient SDK:

```python

from nutrient_sdk import Document
from nutrient_sdk import PdfEditor
from nutrient_sdk import NutrientException

```

This line opens the PDF file. The [context manager](https://docs.python.org/3/reference/datamodel.html#context-managers) syntax ensures the document is automatically closed when you’re done, preventing resource leaks.

> `input.pdf` must exist in your current working directory. If the file is located elsewhere, use an absolute path (for example, `/path/to/input.pdf`).

```python

def main():
    try:
        with Document.open("input.pdf") as document:

```

Here, you create a `PdfEditor` instance that will enable you to manipulate the document. This editor provides all the methods needed for metadata manipulation:

```python

            editor = PdfEditor.edit(document)

```

This block updates the metadata fields. The SDK provides access to standard PDF metadata properties like author, title, subject, and keywords:

```python

            editor.metadata.author = "New author value"
            editor.metadata.title = "New title value"

```

This block exports the XMP metadata as XML. This is useful for inspection, backup, or integration with other systems:

```python

            xmp_metadata = editor.metadata.xmp

            with open("output_metadata.xml", "w", encoding="utf-8") as f:
                f.write(xmp_metadata)

```

This block saves the PDF with the updated properties and closes the editor. The try-except block handles potential errors using `NutrientException`:

```python

            editor.save_as("output.pdf")
            editor.close()
            print("Successfully edited metadata")
    except NutrientException as e:
        print(f"Error: {e}")

if __name__ == "__main__":
    main()

```

## Conclusion

The metadata editing logic consists of four steps:

1. Open the document.

2. Create an editor.

3. Modify metadata properties.

4. Save the result.

Nutrient handles PDF internal structures and XMP schema management so you don’t need to parse PDF internals or manipulate XML directly.

You can download [this ready-to-use sample package](https://www.nutrient.io/downloads/samples/python/editing-pdf-metadata.zip) that’s fully configured to help you get started with the Python SDK.
---

## Related pages

- [Adding a custom page to a PDF document](/guides/python/editor/add-custom-page-to-pdf.md)
- [Adding annotations to a PDF document](/guides/python/editor/add-annotations-to-pdf.md)
- [Adding invisible digital signatures to a PDF document](/guides/python/editor/add-invisible-signature-to-pdf.md)
- [Adding interactive form fields to a PDF document](/guides/python/editor/add-form-fields-to-pdf.md)
- [Adding free text annotations to a PDF document](/guides/python/editor/add-freetext-annotations-to-pdf.md)
- [Adding link annotations to a PDF document](/guides/python/editor/add-link-annotations-to-pdf.md)
- [Adding redaction annotations to a PDF document](/guides/python/editor/add-redaction-annotations-to-pdf.md)
- [Adding shape annotations to a PDF document](/guides/python/editor/add-shape-annotations-to-pdf.md)
- [Adding stamp annotations to a PDF document](/guides/python/editor/add-stamp-annotations-to-pdf.md)
- [Adding sticky note annotations to a PDF document](/guides/python/editor/add-sticky-note-annotations-to-pdf.md)
- [Adding text markup annotations to a PDF document](/guides/python/editor/add-text-markup-annotations-to-pdf.md)
- [Advanced digital signature workflows](/guides/python/editor/advanced-digital-signatures.md)
- [Adding visible digital signatures to a PDF document](/guides/python/editor/add-visible-signature-to-pdf.md)
- [Detecting and adding form fields to a PDF document](/guides/python/editor/detect-and-add-form-fields.md)
- [Editing PDF form fields](/guides/python/editor/editing-pdf-form-fields.md)
- [Managing PDF page order](/guides/python/editor/manage-pdf-page-order.md)
- [Merging PDFs](/guides/python/editor/merge-pdf-into-other-pdf.md)
- [Nutrient Python SDK editor guides](/guides/python/editor.md)
- [Filling PDF form fields](/guides/python/editor/fill-pdf-form.md)

