ZingPDF logo

Guide

How to restrict PDF permissions in C#

Pass PdfEncryptionPermissions to EncryptAsync(...) when the file should open with a password but still limit printing, copying, editing, or form filling.

These permissions are part of the encryption dictionary, so this is always an encryption workflow. If the file is not encrypted, permission flags alone do not apply.

Restrict print and copy access

This example allows printing and form filling, but does not allow copying or general editing.

using ZingPDF;

using var pdf = Pdf.Load(File.OpenRead("input.pdf"));

await pdf.EncryptAsync(
    "user-password",
    "owner-password",
    PdfEncryptionAlgorithm.Aes256,
    PdfEncryptionPermissions.Print | PdfEncryptionPermissions.FillForms);

await pdf.SaveAsync(File.Create("restricted.pdf"));

Common permission flags

The high-level flags exposed by ZingPDF are:

Print, PrintHighQuality, Copy, Modify, Annotate, FillForms, and AssembleDocument.

PdfEncryptionPermissions.All is the default. If you allow PrintHighQuality, ZingPDF also enables normal printing automatically.

Use it for forms that should still be fillable

A common case is a document that users should be able to open, print, and fill out, but not freely copy or edit.

await pdf.EncryptAsync(
    "recipient-password",
    "owner-password",
    PdfEncryptionAlgorithm.Aes256,
    PdfEncryptionPermissions.Print
        | PdfEncryptionPermissions.FillForms
        | PdfEncryptionPermissions.Annotate);

Permissions live inside an encrypted PDF

These flags are written into the Standard security handler dictionary. In practice, PDF viewers decide how strictly to enforce them, so this should be treated as document protection behavior, not as a replacement for access control outside the file.

Need the full encryption setup as well?

The AES guide covers password choice, algorithm choice, and re-encrypting existing files.

Open AES guide Open encryption docs