Skip to content

Keywords

huzpsb edited this page Nov 8, 2026 · 2 revisions

Keywords

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

Command line

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

Pipeline:

cat brochure.pdf | hspdf keywords add - - approved campaign-2026 > brochure-tagged.pdf

Go API

package main

import (
	"context"

	"github.com/huzpsb/hspdf/pkg/api"
	"github.com/huzpsb/hspdf/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