---
title: "Set PDF duplex print preferences in C#"
url: https://recursiveai.org/onepdf/cookbook/set-pdf-print-preferences/
description: "Store duplex and scaling defaults in a PDF. These are viewer hints, not commands to a physical printer. Free, open-source OnePDF example for .NET 10."
version: "1.22.0"
---

# Set PDF duplex print preferences 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-print-preferences/set-pdf-print-preferences.zip)

Store duplex and scaling defaults in a PDF. These are viewer hints, not commands to a physical printer.

```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.SetPrintPreferences(PdfPrintScaling.None,
    PdfDuplex.DuplexFlipLongEdge, copies: 2);
doc.Save("print-ready.pdf");
Console.WriteLine("Saved print-ready.pdf");
```

```text
Saved print-ready.pdf
```

Unzip [the example](https://recursiveai.org/onepdf/cookbook/set-pdf-print-preferences/set-pdf-print-preferences.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 program saves the result and reopens it to inspect the stored settings.

```csharp
using OnePdf;

using var doc = PdfDocument.Open("input.pdf",
    new PdfOpenOptions { AllowEditing = true });
doc.SetViewerPreferences(new PdfViewerPreferences
{
    PrintScaling = PdfPrintScaling.None,
    Duplex = PdfDuplex.DuplexFlipLongEdge,
    NumCopies = 2,
    PrintPageRange = [new PdfPrintPageRange(1, 2)]
});
doc.Save("print-ready.pdf");
using var saved = PdfDocument.Open("print-ready.pdf");
var prefs = saved.ViewerPreferences!;
Console.WriteLine($"Duplex: {prefs.Duplex}");
Console.WriteLine($"Scaling: {prefs.PrintScaling}");
Console.WriteLine($"Copies: {prefs.NumCopies}");
foreach (var range in prefs.PrintPageRange!)
    Console.WriteLine($"Pages: {range.FirstPage}-{range.LastPage}");
```

`dotnet run` prints:

```text
Duplex: DuplexFlipLongEdge
Scaling: None
Copies: 2
Pages: 1-2
```

Invalid ranges or copy counts throw `ArgumentException` without changing the preferences.

## Variations

Request single-sided output and application-default scaling:

```csharp
using OnePdf;

using var doc = PdfDocument.Open("input.pdf",
    new PdfOpenOptions { AllowEditing = true });
doc.SetPrintPreferences(PdfPrintScaling.AppDefault,
    PdfDuplex.Simplex, copies: 1);
doc.Save("single-sided.pdf");
using var saved = PdfDocument.Open("single-sided.pdf");
Console.WriteLine(saved.ViewerPreferences!.Duplex);
```

```text
Simplex
```

## Related recipes

- [Rotate or delete PDF pages](https://recursiveai.org/onepdf/cookbook/rotate-delete-pages/)
- [Add bleed and crop marks](https://recursiveai.org/onepdf/cookbook/add-bleed-and-printer-marks/)

## The short answer

Call `SetPrintPreferences` on an editable PDF to request no print scaling, long-edge duplex and a copy count. For page ranges and other options, use `SetViewerPreferences` with a `PdfViewerPreferences` instance. Save and reopen the file to check the stored values.

These settings are stored inside the PDF as defaults for the viewing application. They describe what a viewer’s print dialog should start with. They do not send a print job, install a driver or force a printer to use both sides.

## How do I set PDF duplex print preferences in C#?

Use `PdfDuplex.DuplexFlipLongEdge` for a long-edge binding request, `DuplexFlipShortEdge` for a short-edge request, or `Simplex` for single-sided output. `PdfPrintScaling.None` requests no scaling; `AppDefault` leaves scaling to the application’s default behavior. The variation demonstrates a single-sided request.

The [typed print settings](https://recursiveai.org/onepdf/docs/print-preferences/) model makes each property nullable. A null property means the entry is absent from the supplied settings; when editing an existing file, it leaves that entry alone. It does not mean “reset everything else.” Set every preference your workflow needs explicitly, particularly when processing PDFs from several sources with different existing defaults.

The full program also records a page range. Its three-page input makes the choice visible: the file still has three pages, but requests printing pages one and two. Setting a print range does not delete any pages. Use page operations instead if the delivered PDF must contain only selected pages.

## Why are PDF print preferences for duplex not working?

OnePDF’s [documentation](https://recursiveai.org/onepdf/docs/print-preferences/) states that it “never enforces” viewer preferences and that viewers treat every entry as a hint. A successful save proves the settings were written, not that a viewer or device will honor them. Reopening the PDF is the first useful check: if `ViewerPreferences.Duplex` has the expected value, the request survived the write.

If the stored value is right but printed output differs, check the viewer’s print dialog and the printer’s own settings. This API does not query printer capabilities or control a physical printer. Applications that must dispatch a job need a separate printing path; changing a PDF dictionary is not that path.

The older `PrintArea`, `PrintClip`, `ViewArea` and `ViewClip` entries are still read and written, but the documentation notes they are deprecated in PDF 2.0 and most viewers ignore them. Do not use those entries as a guarantee that marks or content outside a chosen box cannot print.

## What does “page range” mean when printing?

Use `PdfPrintPageRange(FirstPage, LastPage)` in `PrintPageRange`, as in the full program. These page numbers are one-based and inclusive: `(1, 2)` means the first and second pages. In contrast, `doc.Pages[0]` selects the first page through the document API. Keep those two numbering systems separate.

Ranges must be ascending, nonoverlapping and within the document’s page count. Invalid ranges, an undefined enum value or a copy count below one cause `ArgumentException` without applying the change. Setters also require editing to be enabled. When reading a malformed preference, the normal reader leaves it null and records a diagnostic; strict reading turns warnings into errors. A missing value is therefore not evidence that a particular print choice was enforced or even present in the source.
