[FEATURE REQUEST] Remember PDF export layout per document
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 52/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- android, ios, typescript
- Domain
- backend-api-design, database, mobile
Research direction
Start with app/utils/exportUtils.ts and its named helper tests in app/utils/exportUtils.test.ts, then trace persistence through app/services/documents.ts and app/models/OCRDocument.ts. Follow PDF option merging and platform forwarding in app/services/pdf/PDFExporter.ts, app/workers/PDFExportWorker.ts, and app/components/pdf/PDFPreview.svelte. Done means document layouts persist and reset correctly across export paths on Android and iOS, with the stated tests and checks passing.
Written by the indexing model from the issue text.
Description
Split out of #439 (idea from the maintainer: "remembering card pdf export settings per card").
📋 Context
PDF layout (paper size, orientation, items per page, margin, color, OCR text) is a single global setting today (ApplicationSettings['default_export_options']), rewritten by the PDF preview on every change. Goal: each document remembers its own layout, so re-exporting a card (A4, 2 per page, margin) needs no re-entry.
Assumptions:
- Applies to both apps (scanner and cardwallet), when the exported pages all belong to one document (a partial export of one document counts).
- Only layout keys are stored (
paper_size,orientation,items_per_page,page_padding,color,draw_ocr_text).passwordandjpegQualityare never stored. - No saved layout → fall back to the global options. Reset on a document sets its value to null.
- Synced and backed up with the document (see the compatibility note).
🛠️ Recommended approach
- New nullable column
Document.pdfOptions TEXT(not inextra: avoids thed.extra LIKEsearch noise and the custom-fields display). Migration follows theaddTrashedDatepattern. - Options are merged in one place,
exportPDFAsync: global ← documentpdfOptions← explicit options. This covers open, share, print, export, bulk export (per document) and the preview export. PDFPreviewseeds its options from the same merge and saves layout changes to the document (debounced ~500 ms, flushed on destroy; nomodifiedDatebump, no list notify). Reset setspdfOptionsto null.- Pure helpers in
app/utils/exportUtils.ts:getSingleDocument,pickLayoutOptions,resolvePDFOptions. - iOS: forward
optionsthroughPDFExporter→PDFExportWorker→exporter.export(today iOS ignores them, includingjpegQuality/password). Android:black_whitemust read the mergedcolor. - Sync/backup:
pdfOptionsis written bytoJSONonly when non-null. Compatibility: an older client importing a synced document that carriespdfOptionsfails on the unknown column, so only documents with saved settings are affected.DB_VERSIONis not bumped (it would block every document on older clients).
📂 Impacted files
| File | Action | Description |
|---|---|---|
app/services/documents.ts |
Edit | Column in createTables, migration, update() branch (value ? JSON.stringify(value) : null), parse in createModelFromAttributes |
app/models/OCRDocument.ts |
Edit | pdfOptions field/type; toJSON writes it only when non-null |
app/utils/exportUtils.ts |
Edit | getSingleDocument, pickLayoutOptions, resolvePDFOptions |
app/utils/exportUtils.test.ts |
Edit | Unit tests |
app/services/pdf/PDFExporter.ts |
Edit | Merge options; Android black_white from merged color; pass options to the iOS worker |
app/workers/PDFExportWorker.ts |
Edit | Accept and forward options |
app/services/pdf/PDFCanvas.ts |
Edit | Optional document seed for options |
app/components/pdf/PDFPreview.svelte |
Edit | Seed, debounced per-document save, Reset to null |
No new i18n key (the layout sheet is reused).
📝 Steps
- Helper tests first (red), then the helpers in
exportUtils.ts(green). - Column, migration, model field,
update()null/JSON branch, parse,toJSON(non-null only). - Merged options in
exportPDFAsync(Android) and forwarded to the iOS worker. PDFPreview: seed, debounced save, Reset to null.yarn svelte-check+ eslint on changed files.- Manual run on both platforms.
🧪 Test strategy
| Type | Scenario | File |
|---|---|---|
| Unit | getSingleDocument: one doc → that doc; two docs / empty → undefined |
app/utils/exportUtils.test.ts |
| Unit | pickLayoutOptions drops password and jpegQuality |
app/utils/exportUtils.test.ts |
| Unit | resolvePDFOptions: null → global; override beats global; explicit beats override |
app/utils/exportUtils.test.ts |
| Unit | update() with pdfOptions: null stores SQL NULL, not "null"; toJSON omits null pdfOptions |
next to documents.ts / model (vi.mock NS imports) |
| Manual | Set A4, 2 per page, margin on a card; reopen preview → pre-filled; Export/Share/Print without preview use it; partial export too; another document still uses global; Reset → global. Android + iOS | — |
Refs #439
- Dominant language
- C++
- Stars
- 2.7k
- Forks
- 153
- Avg merge
- 9h 34m
- Merged PRs (30d)
- 123
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ossappscollective/OSS-DocumentScanner
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ossappscollective/OSS-DocumentScanner#739 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 35/100
ossappscollective/OSS-DocumentScanner#891 · 1 comment ·
Maintainers usually reply within 1 day
-
[BUG] Disabling JPEG Compression doesn't actually disable it and exported PDFs still get compressedOpenbug done
Difficulty 3/5 1-2 days Newbie friendliness 48/100
ossappscollective/OSS-DocumentScanner#882 ·
Maintainers usually reply within 1 day
-
android enhancement ios wallet
Difficulty 5/5 Over a week Newbie friendliness 35/100
ossappscollective/OSS-DocumentScanner#865 ·
Maintainers usually reply within 1 day
-
enhancement wallet
Difficulty 5/5 Over a week Newbie friendliness 35/100
ossappscollective/OSS-DocumentScanner#863 ·
Maintainers usually reply within 1 day
All issues in ossappscollective/OSS-DocumentScanner
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
-
triage
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
patrick-hudson/put.gd-desktop#2044 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
uxlfoundation/oneDNN#6604 · 1 comment ·
Maintainers usually reply within 2 days