# Remove a password from a PDF in C#

> Decrypt a password protected PDF in .NET with its owner password and save it unprotected. Reads RC4, AES-128 and AES-256. MIT licensed.

Available since 1.0.

Save an unprotected copy of an encrypted PDF you have the owner password for.

## Short answer

Open the file with its owner password, call `Security.RemoveEncryption`, and save. PdfNetStack
opens every standard security handler revision: RC4 40 to 128 bit, AES-128 and AES-256.

```csharp
PdfDocument doc = PdfDocument.Open("report-protected.pdf", password: "owner-secret");
doc.Security.RemoveEncryption();
doc.Save("report-unprotected.pdf");
```

```bash
dotnet add package PdfNetStack
```

## Notes

The owner password is required: a document opened with only the user password can be read but not
saved. A wrong password raises `PdfPasswordException`.

## Related

- [Encryption](https://www.jadev-corp.com/guides/encryption/)
- [Password protect a PDF](https://www.jadev-corp.com/recipes/password-protect-pdf/)
- [Command line](https://www.jadev-corp.com/cli/): `pdfnetstack decrypt in.pdf out.pdf --password o`
- API: [PdfSecurity](https://www.jadev-corp.com/api/pdfnetstack/pdfsecurity/), [PdfPasswordException](https://www.jadev-corp.com/api/pdfnetstack/pdfpasswordexception/)

Source: https://www.jadev-corp.com/pdfnetstack/recipes/remove-pdf-password/
