Skip to content

Keywords

huzpsb edited this page Oct 25, 2026 · 1 revision

Keywords

Manage the document's keyword list (part of the info dictionary / metadata).

Command line

pdfcpu2 keywords list in.pdf
pdfcpu2 keywords add in.pdf music "virtual instruments"    # one or more
pdfcpu2 keywords add in.pdf out.pdf music                   # with outFile
pdfcpu2 keywords remove in.pdf                              # remove all
pdfcpu2 keywords remove in.pdf out.pdf campaign-2026        # specific

Pipeline:

cat brochure.pdf | pdfcpu2 keywords add - - approved campaign-2026 > brochure-tagged.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()

	err := api.AddKeywordsFile(ctx, "in.pdf", "out.pdf",
		[]string{"approved", "campaign-2026"}, conf)
	if err != nil {
		panic(err)
	}

	err = api.RemoveKeywordsFile(ctx, "in.pdf", "out2.pdf", nil, conf) // nil = all
	_ = err
}

Inspectors: api.Keywords(ctx, rs, conf) ([]string, error); see also Properties and Info.

Clone this wiki locally