Skip to content

Configuration

huzpsb edited this page Nov 8, 2026 · 2 revisions

Configuration

hspdf obtains settings and resources (config file, user fonts, trusted certificates) from a configuration root. Three modes exist:

Mode Selected by Behavior
auto default Uses config.yml, user fonts and trusted certs from the config root; creates missing resources on demand.
stateless --conf disable Built-in settings and the 14 core PDF fonts only. Never touches configuration files. Ideal for containers.
read-only Go API only Loads an existing file-backed configuration without writing. The CLI uses it internally for config inspect / config validate.

Config-root selection order: --conf PATH → PDFCPU_CONFIG_ROOT → OS default location.

Command line

hspdf config init                 # create missing resources at default root
hspdf config list                 # print the stored configuration
hspdf config inspect              # report mode, paths, policy (no writes)
hspdf config inspect --json       # machine readable
hspdf config validate             # validate schema and values
hspdf config reset                # replace with built-in defaults

Typical workflows:

# Service / container with a managed config root
hspdf --conf /srv/app-config config init
hspdf --conf /srv/app-config validate document.pdf

# Immutable container, zero file-system access
hspdf --conf disable validate document.pdf

config.yml highlights

The stored configuration covers validation strictness, encryption defaults, writer behavior and network limits. Notable entries for batch/AI pipelines:

  • localImageRoot — the allowed directory for local images referenced by create / form JSON or CSV (empty = disabled).
  • offline equivalent — or simply pass -o / --offline per invocation to disable all HTTP traffic.
  • timeoutCRL, timeoutOCSP, preferredCertRevocationChecker — used by signatures validate.

Go API

package main

import (
	"context"
	"fmt"

	"github.com/huzpsb/hspdf/pkg/api"
)

func main() {
	// auto mode at the default root
	conf, err := api.LoadConfiguration(api.ConfigurationOptions{})
	if err != nil {
		panic(err)
	}
	_ = conf

	// read-only inspection, nothing gets created or modified
	inspection, err := api.InspectConfiguration(api.ConfigurationOptions{Root: "/srv/app-config"})
	if err != nil {
		panic(err)
	}
	fmt.Println(inspection)
}

model.NewDefaultConfiguration() (see Go API) bypasses the config root entirely and gives you built-in defaults in memory — the quickest way to use hspdf as a library.

Clone this wiki locally