Range Grammar and Page Selection
The range field accepts comma-separated, one-based ranges such as 1-3,5,8-10. Whitespace is ignored, descending ranges are rejected, and out-of-range values are reported or clamped. A bare number selects one page, and duplicates across ranges produce duplicate pages in the selected order. Selection resolves against the actual page tree, so a file with ten leaves cannot yield page eleven even if an inherited /Count is wrong.
Each chosen page is copied with its resources and annotations, inherited /MediaBox and /Rotate are resolved, and /Parent is rewritten. Links whose destination falls outside the exported range become inert, while bookmarks are filtered to surviving pages. Page labels are recomputed for the part instead of being copied verbatim, so a three-page extract of a chapter does not open showing page 47.