Skip to content

Properties

huzpsb edited this page Oct 25, 2026 · 1 revision

Properties

Manage custom document properties (key/value entries of the info dictionary).

Command line

pdfcpu2 properties list in.pdf
pdfcpu2 properties add in.pdf 'key = value'                  # one
pdfcpu2 properties add in.pdf 'key1 = val1' 'key2 = val2'    # several
pdfcpu2 properties remove in.pdf                             # remove all
pdfcpu2 properties remove in.pdf Subject                     # by name

Pipeline:

cat brochure.pdf | pdfcpu2 properties add - - 'Subject = Product Launch' > described.pdf

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()

	props := map[string]string{
		"Subject": "Product Launch",
		"Owner":   "acme",
	}
	err := api.AddPropertiesFile(ctx, "in.pdf", "out.pdf", props, conf)
	if err != nil {
		panic(err)
	}

	err = api.RemovePropertiesFile(ctx, "in.pdf", "out2.pdf", []string{"Subject"}, conf)
	_ = err
}

Inspector: api.Properties(ctx, rs, conf) (map[string]string, error). Related: Keywords, Info.

Clone this wiki locally