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

# Editing PDF metadata with Nutrient Java SDK

Use PDF metadata editing to standardize document properties and improve search workflows.

Common use cases include:

- Updating title and author fields

- Normalizing metadata across large document sets

- Exporting metadata for audit or integration workflows

This guide also shows how to export Extensible Metadata Platform (XMP) metadata as XML.

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

## How Nutrient helps

Nutrient Java SDK provides metadata APIs for reading, updating, and exporting PDF metadata.

The SDK enables you to:

- Update standard properties such as title and author

- Export XMP as XML

- Integrate metadata updates into existing Java workflows

## Preparing the project

Start by specifying a package name and importing the required classes:

```java

package io.nutrient.Sample;

import io.nutrient.sdk.Document;
import io.nutrient.sdk.exceptions.NutrientException;
import io.nutrient.sdk.editors.PdfEditor;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

```

Create the main method and declare checked exceptions used in this sample:

```java

public class PDFMetadataEditor {
    public static void main(String[] args) throws NutrientException, IOException {

```

## Working with PDF metadata

Open the PDF in a [try-with-resources statement](https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html) so Java closes resources after processing.

In this sample, you open from a file path. The SDK also supports streams:

> `input.pdf` must exist in the current working directory. If the file is located elsewhere, use an absolute path (for example, `C:\\docs\\input.pdf`).

```java

        try (Document document = Document.open("input.pdf")) {

```

Create a `PdfEditor` instance to update document metadata:

```java

            PdfEditor editor = PdfEditor.edit(document);

```

## Modifying metadata properties

Update metadata fields such as author and title:

```java

            editor.getMetadata().setAuthor("New author value");
            editor.getMetadata().setTitle("New title value");

```

## Exporting XMP metadata

Export XMP metadata as XML for inspection, backup, or integration:

```java

            String xmpMetadata = editor.getMetadata().getXMP();

            try (FileWriter writer = new FileWriter("output_metadata.xml")) {
                writer.write(xmpMetadata);
            }

```

## Saving the modified PDF

Save the modified PDF after metadata updates:

```java

            editor.saveAs("output.pdf");
            editor.close();
        }
    }
}

```

## Error handling

The sample can throw:

- `NutrientException` for SDK and document-processing issues

- `IOException` for file I/O operations

In production code:

- Catch these exceptions.

- Return clear error messages.

- Log failure details for debugging.

## Conclusion

Use this workflow to edit PDF metadata:

1. Open the document with try-with-resources.

2. Create a `PdfEditor`.

3. Update metadata fields such as author and title.

4. Export XMP metadata with `getXMP()`.

5. Save the modified PDF with `saveAs()`.

For related document workflows, refer to the [Java SDK guides](https://www.nutrient.io/guides/java.md).

Download [this ready-to-use sample package](https://www.nutrient.io/downloads/samples/java/editing-pdf-metadata.zip).
---

## Related pages

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

