Skip to content

Permissions

huzpsb edited this page Oct 25, 2026 · 1 revision

Permissions

Manage user access permissions of protected PDFs: printing, modifying, extracting, form filling, assembling.

Command line

pdfcpu2 permissions list in.pdf
pdfcpu2 permissions set --opw owner --perm print in.pdf out.pdf

Permission modes:

Mode Bits
none 000000000000
print 100000000100
all 111100111100

Or explicitly: 'x' + max 3 hex digits (e.g. xF30) or max 12 binary digits (e.g. 111100110000).

Bit reference:

Bit Permission
3 Print (rev.2) / draft print (rev.3+)
4 Modify contents
5 Copy, extract text & graphics
6 Add/modify annotations, fill forms
9 Fill form fields (rev.3+)
10 Copy/extract (rev.3+, unused since PDF 2.0)
11 Assemble document (rev.3+)
12 Print (rev.3+)

Setting permissions requires the owner password and only applies to encrypted documents (see Encrypt).

Go API

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.OwnerPW = "owner"

	// Print-only via bit pattern (model.PermissionFlags is an int16 bitmask)
	conf.Permissions = model.PermissionFlags(0x804)

	err := api.SetPermissionsFile(ctx, "in.pdf", "out.pdf", conf)
	if err != nil {
		panic(err)
	}

	// Inspect
	p, err := api.GetPermissionsFile(ctx, "in.pdf", conf)
	_ = p
	_ = err
}

Read-only helpers: api.Permissions, api.PermissionsList (human readable strings).

Clone this wiki locally