Skip to content

DocumentRange

DocumentRange pairs a single Document with one or more PageRange selections, and is the input to Extract pages and the per-item payload of MergeRequest.DocumentRanges. Its private constructor substitutes a default all-pages PageRange whenever the supplied array is null or empty, so a range is never truly empty.

Purpose

  • Associates a Document with the specific pages selected from it for extraction or merge operations.
  • Guarantees a usable page selection even when none is supplied, by defaulting to all pages. (BR-30)
  • Renders a human-readable page expression via ToString(), used as PdfResult.Message after extraction. (BR-18)

Context

  • Namespace: PdfAPI.Core
  • Assembly/package: PdfAPI.Core

Public members

Member Signature Purpose
Document Document Document { get; } The document these page ranges apply to.
PageRanges List<PageRange> PageRanges { get; } The page selections to copy from Document.
DocumentRange(Document, PageRange[]) DocumentRange(Document document, params PageRange[] pageRanges) Constructs a range directly from a document and an explicit set of page ranges, defaulting to all pages when none are supplied. (BR-30)
Create(Document, string) static DocumentRange Create(Document document, string pages = "*") Builds a range by parsing a page-expression string via Parse a page expression.
Create(Document, PageRange[]) static DocumentRange Create(Document document, PageRange[] pageRanges) Builds a range from an already-constructed array of page ranges.
Dispose() void Dispose() Disposes the underlying Document, deleting its backing file. (BR-24)
ToString() override string ToString() Renders the page ranges as a comma-joined expression using SAIF.Common.Extensions.ToStringAll.

Behavioral notes

  • Disposing a DocumentRange cascades to disposing its Document, which deletes the document's backing file. (BR-24)

Constraints and usage notes

  • Prefer Create(Document, string) when a caller has a human-authored page expression; use the constructor or Create(Document, PageRange[]) when ranges are already computed.

Sources

  • PdfAPI.Core\Extract\DocumentRange.cs