---
title: "Add a blank page to an existing PDF in C#"
url: https://recursiveai.org/onepdf/cookbook/add-blank-page-to-pdf/
description: "Insert a blank page into an existing PDF in C#. Set the position and page size, then save a new PDF without overwriting the original."
version: "1.25.0"
---

# Add a blank page to an existing PDF 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/add-blank-page-to-pdf/add-blank-page-to-pdf.zip)

Use `report.pdf` from the download 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;

using var doc = PdfDocument.Open("report.pdf",
    new() { AllowEditing = true });
doc.InsertBlankPage(1, 612, 792);
doc.Save("out.pdf");
Console.WriteLine($"Pages: {doc.PageCount}");
```

Unzip [the example](https://recursiveai.org/onepdf/cookbook/add-blank-page-to-pdf/add-blank-page-to-pdf.zip), then `dotnet run`.

Writes `out.pdf` with a blank US Letter page between “Report: Summary” and “Report: Details,” the two pages in the sample. US Letter is 612 × 792 points; A4 is approximately 595 × 842 points.

```text
Pages: 3
```

If you omit `AllowEditing = true`, `InsertBlankPage` throws `InvalidOperationException`.

## Variations

**Append a blank page the size of the final page.** Replace the `InsertBlankPage` line with this. `MediaBox` is the page’s physical boundary, before any crop or rotation.

```csharp
var size = doc.Pages[^1].MediaBox;
doc.InsertBlankPage(doc.PageCount, size.Width, size.Height);
```

## Related recipes

- [Rotate or delete pages in a PDF](https://recursiveai.org/onepdf/cookbook/rotate-delete-pages/)
- [Merge PDF files](https://recursiveai.org/onepdf/cookbook/merge-pdfs/)

## The short answer

Open the existing PDF with `AllowEditing = true`, call `InsertBlankPage(index, width, height)`, then save to a new file. The index is zero-based and the dimensions are in PDF points. There’s no second PDF to create or import: OnePDF builds the empty page directly in the document you opened.

## How do I add a blank page to an existing PDF at a specific position?

Give `InsertBlankPage` the index you want the new page to occupy, not the index of the page it should follow. In a two-page report, index `0` puts the blank page before both originals, `1` puts it between them, and `2` puts it after both. The original pages stay in the same order. For a file of any length, use `doc.PageCount` rather than the last page’s index to append.

An index below zero or beyond `doc.PageCount` throws `ArgumentOutOfRangeException`. If you’ve already read `doc.Pages`, take it again after inserting: the [page operations guide](https://recursiveai.org/onepdf/docs/page-operations/) notes that the earlier page objects are out of date. This matters when you keep editing the PDF before saving it.

## How do I create a blank PDF page that matches the other pages?

`InsertBlankPage` doesn’t copy a neighboring page’s size automatically. The snippet uses `612 × 792` points, the size of the two sample pages. To match the physical size of a page in your own file, take its `MediaBox.Width` and `MediaBox.Height` as in the append variation. Both dimensions have to be finite and greater than zero.

If a neighboring page has been cropped or rotated, decide whether to match the paper or what you see on screen. The [page geometry guide](https://recursiveai.org/onepdf/docs/page-geometry/) distinguishes the physical `MediaBox`, the visible `CropBox`, and rotation. Reading the `MediaBox` size copies neither the crop nor the rotation. It also doesn’t copy the page’s text or graphics: the inserted page has no content of its own.
