Skip to content

OBJ-100 — PDF export endpoint - #35

Merged
objectgyan merged 1 commit into
mainfrom
objectgyan/obj-100-m63-pdf-export-endpoint-streams-playwright-output
May 17, 2026
Merged

objectgyan merged 1 commit into
mainfrom
objectgyan/obj-100-m63-pdf-export-endpoint-streams-playwright-output

Conversation

@objectgyan

Copy link
Copy Markdown
Owner

Summary

  • Implements POST /api/documents/{id}/export-pdf?version=N that streams a Playwright-rendered PDF
  • IPdfExportService (Core) + PdfExportService (Infrastructure) orchestrate: load version → render HTML → Playwright PdfAsync → stream bytes
  • Version-defaults to current (MAX version_number) when ?version is omitted; falls back to live document entity when no versions exist
  • PDF bytes written directly to Response.Body — no intermediate MemoryStream
  • 404 on missing document or version; 500 with error detail on renderer/Playwright failure

Test plan

  • Build passes with 0 warnings (dotnet build --configuration Release)
  • 248 tests pass (dotnet test --configuration Release)
  • scripts/validate-obj-100.ps1 exits 0
    • POST /export-pdf → 200 application/pdf
    • Saved file starts with %PDF- magic bytes
    • Page count >= 1 (verified via /Type /Page regex on raw PDF bytes)
    • ?version=1 returns PDF for that specific version
    • Unknown document → 404
    • Unknown version → 404

POST /api/documents/{id}/export-pdf?version=N
- IPdfExportService (Core) orchestrates renderer + Playwright
- PdfExportService (Infrastructure) loads version, renders HTML, calls Playwright PdfAsync
- Version-defaulting: omit ?version returns MAX(version_number); falls back to live entity
- Error mapping: missing doc/version → 404; renderer/Playwright failure → 500
- Streaming: pdfBytes written directly to Response.Body; no intermediate MemoryStream
- scripts/validate-obj-100.ps1: creates fixture, calls export-pdf, asserts %PDF- magic, page count>=1, 404s
@linear-code

linear-code Bot commented May 17, 2026 •

Copy link
Copy Markdown
OBJ-100 M6.3 — PDF export endpoint streams Playwright output

Milestone M6 - Wave 2

Summary: implement an export endpoint at /api/documents/id/export-pdf that accepts an optional version query parameter, renders the document HTML through Playwright headless Chromium, and streams the resulting PDF back to the caller. No PDF is persisted to disk.

Acceptance:

  • 200 response with application/pdf content type
  • Response is streamed (no full buffer in memory for large docs)
  • Version parameter defaults to current when omitted

Validation:

  • DB check: not applicable
  • Live API check: curl saves the response and the file begins with the PDF magic header; page count matches the expected fixture
  • Validation script: scripts/validate-obj-NNN.ps1

Branch and PR: branch from main using Linear gitBranchName; target main. No commit trailers, no AI footer.

Review in Linear

@objectgyan
objectgyan merged commit 00b5c29 into main May 17, 2026
2 of 3 checks passed
objectgyan added a commit that referenced this pull request May 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant