Skip to content

OP-GET-PAGE-COUNT: Get page count

Validates that submitted bytes are a real PDF, then returns the page count.

Field Value
Operation ID OP-GET-PAGE-COUNT
Trigger Client submits POST v1/info/pages/count with PDF bytes
Entry endpoint POST v1/info/pages/count
Owning component InfoController.GetPageCount(byte[]) → PdfClientService.GetPageCount(byte[])
Inputs Request body: byte[] PDF
Outputs Bare int page count
Failure response No try/catch on this action — any exception produces framework exception detail (IncludeErrorDetailPolicy.Always) before ApiResponseHandler runs; the final client-visible envelope is unknown** (see Endpoints: Error response shape)

Steps

  1. PdfClientService.ValidatePdf checks the %PDF- file signature (BR-PDFAPI-005).
  2. On failure: a PdfException is thrown reporting that the file is not a valid PDF document (exact message text is not visible in this repository); no try/catch on this action, so it escapes to the framework, producing exception detail (IncludeErrorDetailPolicy.Always) before ApiResponseHandler runs; the final client-visible envelope is unknown**.

This validation is implemented in PdfAPI.Core (PdfClientService.ValidatePdf/GetPageCount), documented in full at Validate PDF bytes (OP-01) and Count pages (OP-05); its behavior is summarized here only as observed on this request path.

Origin: The PDF-signature validation and page-counting behaviors described in this step are implemented in PdfAPI.Core, not in PdfAPI. See the linked operation pages for the full delegated logic. 2. PdfClientService.GetPageCount (iTextSharp-based) reads the page count from the validated document. 3. The bare int is returned — HTTP 200.

Process flow

The following diagram shows the validation and page-count sequence.

flowchart TD
    A["POST v1/info/pages/count"] --> B["ValidatePdf: check file signature"]
    B -->|Invalid| C["PdfException escapes to framework: 500"]
    B -->|Valid| D["GetPageCount via iTextSharp"]
    D --> E["Return int, 200"]

Transaction and side effects

Aspect Finding
Unit of work None
Commit point Not applicable — no database access
Records written None
Downstream calls None
Repeat-call behavior Read-only; safe to repeat

Logging

Surface Written content
— No dedicated logging observed on this path beyond framework-level exception logging on an uncaught failure

Error handling

Note: Statements marked with ** could not be confirmed; treat as unknown until verified.

Sources

  • PdfAPI\Controllers\v1\InfoController.cs
  • PdfAPI.Core\Services\PdfClientService.cs