---
title: "Add bleed and crop marks to a PDF in C#"
url: https://recursiveai.org/onepdf/cookbook/add-bleed-and-printer-marks/
description: "Define the finished page size, bleed outside the cut, and a slug—the extra margin outside the bleed—for printer’s marks. This sets boxes and draws marks; it does not extend the artwork. Free, open-source OnePDF example for .NET 10."
version: "1.22.0"
---

# Add bleed and crop marks to a 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-bleed-and-printer-marks/add-bleed-and-printer-marks.zip)

Define the finished page size, bleed outside the cut, and a slug—the extra margin outside the bleed—for printer’s marks. This sets boxes and draws marks; it does not extend the artwork.

```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.

`input.pdf` is the three-page sample in the example zip.

```csharp
using OnePdf;

using var doc = PdfDocument.Open("input.pdf",
    new PdfOpenOptions { AllowEditing = true });
doc.Pages[0].SetPrintGeometry(
    new PdfRectangle(36, 36, 576, 756),
    bleed: 9, slug: 24,
    marks: new PdfPrinterMarks());
doc.Save("press.pdf");
Console.WriteLine("Saved press.pdf");
```

```text
Saved press.pdf
```

Unzip [the example](https://recursiveai.org/onepdf/cookbook/add-bleed-and-printer-marks/add-bleed-and-printer-marks.zip), then `dotnet run`.

`input.pdf` is included in the zip: an original, public-domain sample with three identical, unrotated pages. Each page contains this line in 12-point Helvetica at (72, 700):

```text
Review this figure
```

## The full program

The `PdfRectangle(36, 36, 576, 756)` is the trim box: left, bottom, right and top coordinates in points of 1/72 inch on this sample, measured from the bottom-left. The program changes the first page and reopens the result to print its box dimensions in points. Open `press.pdf` in a PDF viewer to see the crop and registration marks around that page.

```csharp
using OnePdf;

using var doc = PdfDocument.Open("input.pdf",
    new PdfOpenOptions { AllowEditing = true });
doc.Pages[0].SetPrintGeometry(
    new PdfRectangle(36, 36, 576, 756),
    bleed: 9, slug: 24,
    marks: new PdfPrinterMarks());
doc.Save("press.pdf");
using var saved = PdfDocument.Open("press.pdf");
var page = saved.Pages[0];
Console.WriteLine($"Trim: {page.TrimBox.Width} x {page.TrimBox.Height}");
Console.WriteLine($"Bleed: {page.BleedBox.Width} x {page.BleedBox.Height}");
Console.WriteLine($"Media: {page.MediaBox.Width} x {page.MediaBox.Height}");
Console.WriteLine($"Explicit trim: {page.HasExplicitBox(PdfPageBox.TrimBox)}");
```

`dotnet run` prints:

```text
Trim: 540 x 720
Bleed: 558 x 738
Media: 606 x 786
Explicit trim: True
```

If the slug is too small, `ArgumentException` is thrown and the page is unchanged.

## Variations

Apply the same trim box, bleed and marks to every page of this uniformly sized sample:

```csharp
using OnePdf;

using var doc = PdfDocument.Open("input.pdf",
    new PdfOpenOptions { AllowEditing = true });
foreach (var page in doc.Pages)
{
    page.SetPrintGeometry(
        new PdfRectangle(36, 36, 576, 756),
        bleed: 9, slug: 24,
        marks: new PdfPrinterMarks());
}
doc.Save("all-pages-press.pdf");
using var saved = PdfDocument.Open("all-pages-press.pdf");
for (int i = 0; i < saved.Pages.Count; i++)
{
    var page = saved.Pages[i];
    Console.WriteLine($"Page {i + 1}: trim {page.TrimBox.Width} x {page.TrimBox.Height}");
}
```

```text
Page 1: trim 540 x 720
Page 2: trim 540 x 720
Page 3: trim 540 x 720
```

Handle a slug that cannot contain the default marks:

```csharp
using OnePdf;

using var doc = PdfDocument.Open("input.pdf",
    new PdfOpenOptions { AllowEditing = true });
try
{
    doc.Pages[0].SetPrintGeometry(
        new PdfRectangle(36, 36, 576, 756),
        bleed: 9, slug: 10,
        marks: new PdfPrinterMarks());
}
catch (ArgumentException)
{
    Console.WriteLine("Refused: slug too small; page unchanged.");
}
```

```text
Refused: slug too small; page unchanged.
```

## Related recipes

- [Rotate or delete PDF pages](https://recursiveai.org/onepdf/cookbook/rotate-delete-pages/)
- [Set PDF print preferences](https://recursiveai.org/onepdf/cookbook/set-pdf-print-preferences/)

## The short answer

Call `SetPrintGeometry` with an explicit trim rectangle, bleed and slug, and pass a `PdfPrinterMarks` object to draw marks. Save the PDF and reopen it to inspect the stored page boxes. The example requests a nine-point bleed and a 24-point slug around a 540-by-720-point finished page.

Bleed is the area outside the intended cut. The slug is additional space outside the bleed where marks can sit. Setting these rectangles does not generate missing image pixels, stretch artwork or repair a design whose background ends at the trim edge. Artwork intended to bleed must already extend through that area.

## Can I add bleed and crop marks to a PDF?

Yes. The [page geometry API](https://recursiveai.org/onepdf/docs/page-geometry/) can change the boxes of an existing page and add printer’s marks as page content. The full program edits only the first page of its three-page sample. Its explicit trim rectangle leaves the text in place; the call changes geometry without translating or scaling existing content.

The bleed box is the trim rectangle expanded by the bleed on each side. The media box expands that bleed box again by the slug. The sample’s dimensions therefore grow from 540 by 720 at trim to 558 by 738 at bleed, and then 606 by 786 at media. These are PDF coordinate units; the sample uses the normal user unit. The API also supports unequal margins on different sides through `PdfPrintMargins`.

The call clears the crop box so it does not continue clipping to an older size. If you need a separate crop policy afterward, set it deliberately rather than assuming the old crop rectangle still applies. Reopening and inspecting effective box values helps catch mistaken coordinates before sending a file downstream.

## Should I include crop marks and bleed?

Use the production geometry requested by the recipient of the file. With this API, bleed and marks are separate choices: you can set print geometry without supplying marks. A printer that wants bleed but no marks does not need a `PdfPrinterMarks` object added to the call.

When you do request marks, reserve enough slug space. The default `MinimumSlug` is 18.125 points, derived from the gap, longest mark and half the line width. The example uses 24 points on every side. The variation requests only ten and catches the refusal. The library does not silently shorten the marks: insufficient room throws `ArgumentException` and changes nothing.

The `Offset`, `Length`, `RegistrationSize` and `LineWidth` options affect the space required. Disabling a kind of mark removes its space requirement. Check the required slug for the settings you actually supply rather than treating the default as a universal prepress specification.

## What do bleed marks look like on a PDF?

OnePDF draws crop marks as horizontal and vertical strokes at each trim corner, reaching outward. Registration marks are circles with crosshairs centered on each side’s trim edge. It does not draw color bars. All these marks lie in the slug, outside the bleed and inside the media box.

The [documentation](https://recursiveai.org/onepdf/docs/page-geometry/) specifies registration color using a Separation All color space, with DeviceGray as its alternate. In a separated print job the marks print on every plate; other viewers show them black. They are page content, not PrinterMark annotations. On an existing page they are added in a separate stream over the content.

The marks are wrapped in an Artifact marked-content sequence of type Page, so tagged output treats them as page artifacts rather than reading content. That is distinct from the viewer print-preference API: geometry and marks change the page itself, while duplex or scaling preferences merely request print-dialog defaults.
