Flatten configuration/ qpdf expansion
Author: glowskirCreated Oct 8, 2025Updated Feb 12, 2026
Labelsenhancementpdf-enginesmaybe
For now Gotenberg supports flatten route which looks like this
// Flatten merges annotation appearances with page content, deleting the
// original annotations.
func (engine *QPdf) Flatten(ctx context.Context, logger *zap.Logger, inputPath string) error {
var args []string
args = append(args, inputPath)
args = append(args, "--generate-appearances")
args = append(args, "--flatten-annotations=all")
args = append(args, "--replace-input")
args = append(args, engine.globalArgs...)
cmd, err := gotenberg.CommandContext(ctx, logger, engine.binPath, args...)
if err != nil {
return fmt.Errorf("create command: %w", err)
}
_, err = cmd.Exec()
if err == nil {
return nil
}
return fmt.Errorf("flatten PDFs with QPDF: %w", err)
}I would like to be able convert PDFs using fine tuned configuration passed to QPDF. Flatten does this to an extent but QPDF configuration here is hardcoded. Would you be interested in allowing more configuration options via cli parameters/env variables to flatten route or perhaps creating new route ? I could contribute pull request if so.
Source: gotenberg/gotenberg