Skip to content

AI Generation: Add PDF document input support #70

@johlju

Description

@johlju

Summary

Allow users to attach PDF documents as context when generating requirements with the AI feature. PDFs (e.g. specifications, standards documents, process descriptions) would be sent alongside the text prompt so the model can reference their content.

Background

Image attachment support has been implemented (vision-capable models). PDF support is the next step for richer document context.

Approaches

Option A: OpenRouter file-parser plugin

OpenRouter offers a file-parser plugin that accepts PDF URLs or base64 data and extracts text server-side before sending to the model.

  • Pros: No additional dependencies; works with any text model (not just vision models)
  • Cons: Plugin availability and cost may vary; file size limits apply; relies on OpenRouter's extraction quality

Option B: Client-side extraction with pdf.js

Use Mozilla's pdf.js (or pdfjs-dist) to extract text from the PDF in the browser, then send the extracted text as part of the prompt.

  • Pros: No server-side dependency; full control over extraction; works with any model
  • Cons: Adds ~500 KB bundle size; complex PDFs (tables, images, scanned docs) may extract poorly; layout information is lost

Considerations

  • Token consumption: PDF text can be very large. Need a character/token limit with a warning, similar to the existing image token cost warning.
  • File size limit: Suggest max 20 MB per PDF.
  • Max file count: Suggest max 2 PDFs (in addition to images).
  • Scanned PDFs: Neither approach handles scanned/image-only PDFs well without OCR. Could combine with vision models for scanned pages.
  • UI: Could reuse the existing image drop zone — extend accepted MIME types and show a document icon for PDFs instead of a thumbnail preview.

Acceptance Criteria

  • User can attach PDF files in the AI generation dialog when a supported capability is active
  • PDF content is sent to the model as text context
  • File size and count limits are enforced with clear error messages
  • Token cost warning is shown for attached PDFs
  • Translation keys added for both en and sv

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions