Skip to content
huzpsb edited this page Oct 25, 2026 · 1 revision

Info

Print metadata about PDF files: page count, page sizes, version, encryption, tagged/PDF-A hints — optionally with font details, as JSON.

Command line

pdfcpu2 info [--fonts] [-j|--json] inFile...
Flag Meaning
--fonts include font info
-j, --json JSON output
-p, --pages restrict page analysis to a selection
-u, --unit display unit for dimensions: po(ints)|in(ches)|cm|mm
pdfcpu2 info in.pdf
pdfcpu2 info --fonts in.pdf
pdfcpu2 info --json in.pdf | jq '.infos[] | {source, pageCount}'

Go API

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/huzpsb/pdfcpu2/pkg/api"
	"github.com/huzpsb/pdfcpu2/pkg/pdfcpu/model"
)

func main() {
	ctx := context.Background()
	conf := model.NewDefaultConfiguration()

	f, err := os.Open("in.pdf")
	if err != nil {
		panic(err)
	}
	defer f.Close()

	// nil page selection = all pages; true = include fonts
	info, err := api.PDFInfo(ctx, f, "in.pdf", nil, true, conf)
	if err != nil {
		panic(err)
	}
	fmt.Println("pages:", info.PageCount)
}

Shortcut for just the page count or page dimensions:

n, err := api.PageCountFile(ctx, "in.pdf")       // int
dims, err := api.PageDimsFile(ctx, "in.pdf")     // []types.Dim, one per page

Clone this wiki locally