|
4 | 4 | # POST /api/v1/templates |
5 | 5 | # PUT /api/v1/templates/{template_id} |
6 | 6 | # GET /api/v1/templates/{template_id}/fields |
| 7 | +# POST /api/v1/templates/pdf |
7 | 8 |
|
8 | 9 | templates: |
9 | 10 | get: |
@@ -304,3 +305,102 @@ template_fields: |
304 | 305 | application/json: |
305 | 306 | schema: |
306 | 307 | $ref: "../schemas/common.yaml#/ErrorResponse" |
| 308 | + |
| 309 | +templates_pdf: |
| 310 | + post: |
| 311 | + operationId: uploadTemplatePdf |
| 312 | + summary: Upload a blank PDF for a template before defining its fields |
| 313 | + description: | |
| 314 | + Uploads the blank agency PDF that a template's field coordinates will be |
| 315 | + written onto, and returns a `pdf_template_ref` plus the page geometry. |
| 316 | +
|
| 317 | + This is the first step of the template-authoring flow. The visual editor |
| 318 | + renders the returned pages, the user draws a box per field, and the box |
| 319 | + coordinates become each field's `layout`. The resulting `pdf_template_ref` |
| 320 | + is then sent in the `POST /api/v1/templates` body. Upload precedes create |
| 321 | + because the layout coordinates only have meaning relative to this PDF. |
| 322 | +
|
| 323 | + Page dimensions are returned in PDF points (1/72 inch, origin bottom-left) |
| 324 | + so the editor can map canvas positions to the same coordinate system the |
| 325 | + `layout` fields use. |
| 326 | + tags: |
| 327 | + - templates |
| 328 | + requestBody: |
| 329 | + required: true |
| 330 | + content: |
| 331 | + multipart/form-data: |
| 332 | + schema: |
| 333 | + type: object |
| 334 | + required: |
| 335 | + - pdf_file |
| 336 | + properties: |
| 337 | + pdf_file: |
| 338 | + type: string |
| 339 | + format: binary |
| 340 | + description: Blank fillable or flat PDF form. Max 50MB. |
| 341 | + responses: |
| 342 | + "201": |
| 343 | + description: PDF stored and ready to be referenced by a template |
| 344 | + content: |
| 345 | + application/json: |
| 346 | + schema: |
| 347 | + type: object |
| 348 | + required: |
| 349 | + - pdf_template_ref |
| 350 | + - original_filename |
| 351 | + - page_count |
| 352 | + - pages |
| 353 | + properties: |
| 354 | + pdf_template_ref: |
| 355 | + type: string |
| 356 | + description: Opaque reference to the stored PDF, passed back in |
| 357 | + the template body as pdf_template_ref |
| 358 | + original_filename: |
| 359 | + type: string |
| 360 | + page_count: |
| 361 | + type: integer |
| 362 | + pages: |
| 363 | + type: array |
| 364 | + description: Per-page geometry in PDF points, index 0 = first page |
| 365 | + items: |
| 366 | + type: object |
| 367 | + required: |
| 368 | + - page |
| 369 | + - width |
| 370 | + - height |
| 371 | + properties: |
| 372 | + page: |
| 373 | + type: integer |
| 374 | + width: |
| 375 | + type: number |
| 376 | + height: |
| 377 | + type: number |
| 378 | + example: |
| 379 | + pdf_template_ref: "templates/uploads/550e8400-e29b-41d4-a716-446655440080.pdf" |
| 380 | + original_filename: "texas_sfm_incident.pdf" |
| 381 | + page_count: 2 |
| 382 | + pages: |
| 383 | + - page: 0 |
| 384 | + width: 612.0 |
| 385 | + height: 792.0 |
| 386 | + - page: 1 |
| 387 | + width: 612.0 |
| 388 | + height: 792.0 |
| 389 | + "400": |
| 390 | + description: Missing file or malformed multipart request |
| 391 | + content: |
| 392 | + application/json: |
| 393 | + schema: |
| 394 | + $ref: "../schemas/common.yaml#/ErrorResponse" |
| 395 | + "413": |
| 396 | + description: PDF exceeds the maximum allowed size |
| 397 | + content: |
| 398 | + application/json: |
| 399 | + schema: |
| 400 | + $ref: "../schemas/common.yaml#/ErrorResponse" |
| 401 | + "415": |
| 402 | + description: Uploaded file is not a valid PDF |
| 403 | + content: |
| 404 | + application/json: |
| 405 | + schema: |
| 406 | + $ref: "../schemas/common.yaml#/ErrorResponse" |
0 commit comments