> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chromiumly.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# PDF encryption

> Protect PDFs with user and owner passwords using userPassword and ownerPassword.

Chromium converters, LibreOffice, and `PDFEngines.merge()`/`PDFEngines.split()` support PDF encryption via `userPassword` and `ownerPassword`:

* **userPassword** — Required to open the PDF.
* **ownerPassword** — Grants full access (e.g. printing, copying). If only `userPassword` is set, the document can still be opened with that password.

```typescript theme={null}
import { UrlConverter } from "chromiumly";

const buffer = await new UrlConverter().convert({
  url: "https://example.com/",
  userPassword: "open_secret",
  ownerPassword: "admin_secret",
});
```

Same options exist on `HtmlConverter`, `MarkdownConverter`, `LibreOffice.convert()`, `PDFEngines.merge()`, and `PDFEngines.split()`.

> [!NOTE]
>
> Screenshot routes (`UrlScreenshot`, `HtmlScreenshot`, `MarkdownScreenshot`)
> produce an image, not a PDF, and don't accept `userPassword`/`ownerPassword`
> at all.

Each route above also accepts six permission booleans (`allowPrinting`, `allowCopying`, `allowModifying`, `allowAnnotating`, `allowFillingForms`, `allowAssembling`), each defaulting to `true`. See [PDF permissions](https://docs.chromiumly.dev/v6/advanced/permissions.md).

## Encrypting existing PDFs

There's also a dedicated `PDFEngines.encrypt()` route for encrypting existing PDFs directly, without a conversion. Unlike the routes above, it requires **at least one** of `userPassword` or `ownerPassword`; since Gotenberg 8.34.0, an owner-password-only request produces an owner-only PDF that opens without a password but still enforces permissions.

```typescript theme={null}
import { PDFEngines } from "chromiumly";

const encrypted = await PDFEngines.encrypt({
  files: ["path/to/document.pdf"],
  options: {
    userPassword: "my_user_password",
    ownerPassword: "my_owner_password",
    allowPrinting: false,
  },
});
```

See [Encrypt PDFs](https://docs.chromiumly.dev/v6/pdf-engines/encrypt.md) for the full dedicated-route reference.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.