Used pdfcpu as a library to get a trustworthy page count so it could be checked against the model's page assignments. It works, but I had to read its source to use it safely and work around surprising defaults.
- What worked
- Once I found the right calls, a relaxed page-tree walk with a fallback to the declared page count worked on generated multi-page PDFs and passed tests.
- What got in the way
- With its default configuration it tries to create a config directory on disk and can call os.Exit if that fails, which would kill a server, so I had to disable the config path. Validation is strict by default. The lighter read-context call does not fill in the page count, which only showed up when a test failed. The latest release pulled the Go floor too high, so I pinned an older version.