Skip to content

ExtractController

ExtractController extracts one or more page ranges from a source PDF document into a new output document.

Field Value
Controller ExtractController
Base System.Web.Http.ApiController
Route prefix [RoutePrefix("v1")]
Source PdfAPI\Controllers\v1\ExtractController.cs
Controller-level authorization None in code
Error handling Per-action try/catch + ILogService.LogException; response then passes through ApiResponseHandler, whose final outer envelope is unknown** (details)
Endpoints 1

POST v1/extract

Validates that the supplied document is a real PDF, then extracts the requested page ranges into a new output document.

Field Value
HTTP verb POST
Resolved route v1/extract
Route composition [RoutePrefix("v1")] + [Route("extract")]
Action ExtractPages(ExtractPagesRequest request)
Return type IHttpActionResult (Ok(result))
Authorization None in code
Idempotent No — a repeat call can create a new PDFTracking record and a new output document*
Operation OP-EXTRACT-PAGES

Parameters

Name In Type Required Default Binding Purpose
request Body PdfAPI.Core.ExtractPagesRequest Yes — Implicit complex-type body binding* The source document and the page ranges to extract

Request

Field Value
DTO PdfAPI.Core.ExtractPagesRequest (PdfAPI.Core\Request\ExtractPagesRequest.cs)
Media type application/json
Validation Document validity is checked by BR-PDFAPI-004 before extraction runs
Property Type Required Constraints Purpose
DocumentRange DocumentRange Yes — The source document plus one or more PageRange entries

Response

Field Value
DTO PdfAPI.Core.PdfResult
Media type application/json
Property Type Nullable Purpose
Status PdfStatus No Result of the extraction
Document Document Yes The extracted output document

Status codes

Status Condition Body
200 OK Extraction succeeds, or a failure is caught and returned as a failed PdfResult PdfResult

Errors

Error status Trigger Produced by Body
500 Internal Server Error None identified — a null request is dereferenced only inside the try block, and the catch tolerates a null request when constructing PdfResult* — —

Business rules

  • BR-PDFAPI-004 — page extraction validates that the source document is a real PDF before any extraction work.
  • BR-PDFAPI-018 — page ranges are clamped to the document's page count, out-of-range ranges are skipped, descending ranges extract pages in reverse order, and a single IsOriginal range returns the original file untouched.

Authorization

No authorization attribute or programmatic check is present. See Authentication and authorization.

Side effects and idempotency

Aspect Finding
Records written PDFTracking, when tracking is enabled for the request (see Data model)
Downstream calls None identified
Files or messages produced Extracted output document written to pdfapi.rootdirectory
Repeat-call behavior Each call produces a new tracking record and a new output document*

Example

POST v1/extract HTTP/1.1
Host: <host>
Content-Type: application/json

{
  "DocumentRange": {
    "Document": { "File": "<base64 bytes>" },
    "PageRanges": [ { "StartPage": 1, "StopPage": 3 } ]
  }
}
HTTP/1.1 200 OK
Content-Type: application/json

{
  "Status": "Succeeded",
  "Document": { "FileName": "extracted.pdf" }
}

Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with ** could not be confirmed; treat as unknown until verified.

Sources

  • PdfAPI\Controllers\v1\ExtractController.cs
  • PdfAPI.Core\Request\ExtractPagesRequest.cs
  • PdfAPI.Core\Extract\DocumentRange.cs
  • PdfAPI.Core\Extract\PageRange.cs
  • PdfAPI.Core\PdfResult.cs