Repository navigation
Decrypt
huzpsb edited this page Oct 25, 2026
·
1 revision
Remove password protection (user + owner password) and reset permissions, producing an unencrypted PDF.
pdfcpu2 decrypt --upw secret in.pdf out.pdf
pdfcpu2 decrypt --opw owner in.pdf out.pdf
pdfcpu2 decrypt --upw-file /run/secrets/upw in.pdf out.pdf # password file
cat onboarding.pdf | pdfcpu2 decrypt --upw "$UPW" - - > plain.pdfSupply whichever password you have — an owner password also authenticates.
package main
import (
"context"
"github.com/huzpsb/pdfcpu2/pkg/api"
"github.com/huzpsb/pdfcpu2/pkg/pdfcpu/model"
)
func main() {
ctx := context.Background()
conf := model.NewDefaultConfiguration()
conf.UserPW = "secret"
err := api.DecryptFile(ctx, "in.pdf", "out.pdf", conf)
if err != nil {
panic(err)
}
}One-off alternative without decrypting to disk: pdfcpu2 optimize --rmenc in.pdf out.pdf — see Optimize.
pdfcpu2 wiki
Getting started
Fork features
Inspect
Document
Pages
Content
Extract
Resources
Security
Viewer
Trust
Developers