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¶
PdfClientService.ValidatePdfchecks the%PDF-file signature (BR-PDFAPI-005).- On failure: a
PdfExceptionis thrown reporting that the file is not a valid PDF document (exact message text is not visible in this repository); notry/catchon this action, so it escapes to the framework, producing exception detail (IncludeErrorDetailPolicy.Always) beforeApiResponseHandlerruns; 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 inPdfAPI. 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 bareintis returned — HTTP200.
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¶
- Non-PDF payload:
PdfExceptionescapes uncaught, producing framework exception detail beforeApiResponseHandlerruns; the final client-visible envelope is unknown** (BR-PDFAPI-005; see Endpoints: Error response shape).
Related documentation¶
- API index
- Overview
- Architecture
- Endpoints
- Authentication and authorization
- Dependencies
- Configuration
- Operations and processes
- Business rules
- Data model
- Operational runbook
- Tech debt
Note: Statements marked with
**could not be confirmed; treat as unknown until verified.
Sources¶
- PdfAPI\Controllers\v1\InfoController.cs
- PdfAPI.Core\Services\PdfClientService.cs