---
title: "Set PDF title and author in C#"
url: https://recursiveai.org/onepdf/cookbook/set-pdf-document-metadata/
description: "Set the title and author of an existing PDF in C# with OnePDF. Edit its document properties, save a copy, and read the values back from disk."
version: "1.25.0"
---

# Set PDF title and author in C#

**OnePDF** is a free, open-source PDF library for .NET from Recursive AI. MIT or Apache-2.0, no native dependencies.

[NuGet](https://www.nuget.org/packages/RecursiveAI.OnePdf) · [GitHub](https://github.com/recursive-ai-oss/onepdf-csharp) · [Docs](https://recursiveai.org/onepdf/docs/) · [Download example (.zip)](https://recursiveai.org/onepdf/cookbook/set-pdf-document-metadata/set-pdf-document-metadata.zip)

Use `report.pdf` from the zip or your own PDF.

```shell
dotnet add package RecursiveAI.OnePdf
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.


```csharp
using OnePdf;
var edit = new PdfOpenOptions
    { AllowEditing = true };
using var pdf = PdfDocument.Open(
    "report.pdf", edit);
pdf.SetInfo("Title", "Quarterly report");
pdf.SetInfo("Author", "Jordan Lee");
pdf.Save("report-updated.pdf");
Console.WriteLine("Wrote report-updated.pdf");
```

Unzip [the example](https://recursiveai.org/onepdf/cookbook/set-pdf-document-metadata/set-pdf-document-metadata.zip), then `dotnet run`.

This writes `report-updated.pdf` with new `Title` and `Author` entries in its Info dictionary, the PDF’s document-properties record.

```text
Wrote report-updated.pdf
```

## The full program

The one-page sample is headed “Quarterly report draft.” Its original document title is “Draft” and author is “Editorial team.” The program reopens the saved copy to print the updated values from disk.

```csharp
using OnePdf;

var options = new PdfOpenOptions { AllowEditing = true };
using var pdf = PdfDocument.Open("report.pdf", options);
pdf.SetInfo("Title", "Quarterly report");
pdf.SetInfo("Author", "Jordan Lee");
pdf.Save("report-updated.pdf");

using var saved = PdfDocument.Open("report-updated.pdf");
Console.WriteLine($"Title: {saved.Info.Title}");
Console.WriteLine($"Author: {saved.Info.Author}");
```

```text
Title: Quarterly report
Author: Jordan Lee
```

OnePDF opens PDFs read-only by default; without `AllowEditing = true`, `SetInfo` throws `InvalidOperationException`.

## Variations

Add these calls just before `pdf.Save(...)` to save a subject and keywords in the same Info dictionary:

```csharp
pdf.SetInfo("Subject", "Quarterly operations");
pdf.SetInfo("Keywords", "operations, quarterly");
```

To remove the Info author entry rather than replacing it, change the `Author` call to:

```csharp
pdf.SetInfo("Author", null);
```

## Related recipes

- [Save changes to a PDF](https://recursiveai.org/onepdf/cookbook/save-as-pdf/)
- [Create a PDF in C#](https://recursiveai.org/onepdf/cookbook/create-pdf/)

## The short answer

Open the PDF with editing enabled, call `SetInfo("Title", ...)` and `SetInfo("Author", ...)`, then call `Save` with a different path. `SetInfo` creates the Info dictionary if the PDF doesn’t already have one. It updates only the entry you name, so you can fix the author without supplying a new title or subject. The sample leaves the input file untouched.

## Why does the title of my PDF not match the filename?

`report-updated.pdf` is the name of the saved file. `Quarterly report` is its document title. A reader can display the stored title instead of the filename, so renaming the file isn’t a way to correct its title. Likewise, setting `Title` won’t rename the file or replace a heading printed on page one. Open the new file’s document properties or read `Info.Title` and `Info.Author` as the full program does to check the values you saved. Setting `Author` also doesn’t change who is listed as the author of an existing comment or annotation.

## What is XMP metadata in a PDF?

XMP is an XML metadata packet that a PDF can store separately from its Info dictionary. A file can have both, and the same properties can appear in both places. `SetInfo` changes the Info dictionary only. If an app reads title or author from XMP, it can still see old values even though the new file’s Info entries are correct.

If both stores matter for your workflow, update each one. OnePDF exposes the XMP packet separately and takes replacement XML bytes through `SetXmp`. That replaces the whole packet rather than patching a field. Preserve the other XML properties your workflow needs when preparing the replacement. The sample has no XMP packet to update. See the [OnePDF writing reference](https://recursiveai.org/onepdf/docs/writing/#the-mutable-view) for both APIs.
