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

# Encrypt PDFs

> Encrypt existing PDFs with PDFEngines.encrypt, or via userPassword/ownerPassword on convert, merge, and split.

## PDFEngines.encrypt

Encrypts existing PDFs directly using Gotenberg's [encrypt route](https://gotenberg.dev/docs/8.x/manipulate-pdfs/encrypt-pdfs), without going through a conversion:

```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,
    allowCopying: false,
  },
});
```

At least one of `userPassword` or `ownerPassword` is required. Since Gotenberg 8.34.0, an owner-password-only request produces an owner-only PDF that opens without a password but still enforces the given permissions.

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

`downloadFrom`, `webhook`, `outputFilename`, and `trace` are also accepted — see [Request tracing](https://docs.chromiumly.dev/v6/advanced/request-tracing.md).

## Encryption on other routes

The same `userPassword`/`ownerPassword` and permission fields are also available directly on:

* Chromium converters (`UrlConverter`, `HtmlConverter`, `MarkdownConverter`) `convert()`
* `LibreOffice.convert()`
* `PDFEngines.merge()` and `PDFEngines.split()`

See [Encryption](https://docs.chromiumly.dev/v6/advanced/encryption.md) and [PDF permissions](https://docs.chromiumly.dev/v6/advanced/permissions.md) for the full cross-cutting reference.


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