[FEATURE REQUEST] Card-size PDF export for cards (cardwallet)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- ios, kotlin, typescript
- Domain
- full-stack, mobile
Research direction
Start with app/utils/pdfPaper.ts and its proposed tests, then trace PDF sizing and drawing through app/services/pdf/PDFCanvas.ts, app/services/pdf/PDFExportCanvas.ios.ts, and the Android PDFUtils.kt path listed in the issue. Check how PDF_OPTIONS controls cardwallet settings and preview behavior. Done means cardwallet exports one correctly sized page per card side with fitted images, and the optional rounded corners work in preview and on Android and iOS.
Written by the indexing model from the issue text.
Description
Is your feature request related to a problem?
Exporting an ID card (2 sides) to PDF gives either huge pages (full = image pixels as points, not a physical size) or A4 sheets. There is no way to get one card side per card-sized page, nor to clip the scan to the rounded corners of the card. Split out of #439 (maintainer idea: an export preset with "card size" pages). Refs #439.
Describe the solution you'd like
In the cardwallet app only: a card paper size (ISO/IEC 7810 ID-1, 85.6 x 54 mm = 242.65 x 153.07 pt), one card side per page, plus an optional "rounded corners" switch.
🎯 Plan
📋 Context
Extension of the PDF export options. Cardwallet only (CARD_APP); the document scanner app is untouched.
Assumptions:
- "1 page with card size pages" = one card side per card-size page (2 pages for a 2-sided card). Both sides on one sheet is already covered by A4 + 2 items per page.
- Preset = one new
paper_sizevalue, not a named option bundle. - Corner radius is a ratio of the short side (3.18 / 53.98 = 0.059): exact only when the scan is cropped to the card.
- PKPass pages are not card-fitted (they keep their own layout); only image pages are.
🛠️ Recommended approach
- New
paper_size: 'card', added toPDF_OPTIONS.paper_sizeonly whenCARD_APP. Settings, sync settings and the layout sheet menu are built fromPDF_OPTIONS, so no extra UI is needed. - It behaves like
full(1 item per page, margins ignored) with a fixed physical size. Orientation follows the first image (landscape or portrait), so picking it from Settings alone gives a correct page. The image is fitted and centered, embedded at full resolution. round_cornersboolean (default off), shown only in cardwallet and usable with any paper size (also A4 2-up). Applied at image draw time, before rotation: Android masks the bitmap inloadImageand writes the corners white (keeps JPEG); iOS usescanvas.clipPathwith a rounded rect. White corners are invisible on a white page.- Page sizes are hardcoded in 4 places today (Kotlin, iOS switch,
PDFCanvasratio switch,PDFPreviewPAPERS): share one TS tableapp/utils/pdfPaper.tsfor the 3 TS callers; Kotlin keeps its own constants with a "keep in sync" comment (as for the OCR constants). - Per-card remembered export settings (separate idea) compose:
cardandround_cornersare plain option keys. On AndroidexportPDFAsyncmerges the persisteddefault_export_optionswith the passedoptions, so per-card options must be passed explicitly.
📂 Impacted files
| File | Action | Description |
|---|---|---|
app/utils/pdfPaper.ts (+ .test.ts) |
Create | PAPERS in pt (card included), isSinglePage(paper_size), getCardPageSize(w, h, rotation) |
app/utils/constants.ts |
Edit | CARD_CORNER_RADIUS_RATIO; round_corners: false in DEFAULT_PDF_OPTIONS and PDF_LAYOUT_KEYS |
app/utils/localized_constant.ts |
Edit | paper_size.card, only when CARD_APP |
app/services/pdf/PDFCanvas.ts |
Edit | card through the single-page branch of updatePages / drawPages; fit and center; round_corners clip |
app/services/pdf/PDFExportCanvas.ios.ts |
Edit | card case in the size switch; no orientation swap for card |
plugin-nativeprocessor/platforms/android/.../PDFUtils.kt |
Edit | card branch (page size, fit and center, OCR offset); round_corners mask in loadImage |
app/components/pdf/PDFPreview.svelte |
Edit | Use pdfPaper.ts; card sheet ratio from the first page; margin 0; rounded <image> preview |
app/components/pdf/PDFLayoutSheet.svelte |
Edit | Dim orientation / items / margin for card like full; "rounded corners" switch row (cardwallet only) |
app/i18n/en.json |
Edit | card_size, pdf_layout_card_hint, round_corners, round_corners_desc |
📝 Steps
pdfPaper.tstest-first (red, then green). WirePDFPreviewandPDFCanvasto it, no behaviour change.- Add
cardto constants and labels (cardwallet only). Preview and layout sheet show it, with the hint. - iOS export for
card; Androidcardbranch in Kotlin. - Add
round_corners: option, sheet row, iOS clip, Android mask, preview radius. yarn svelte-check, eslint on changed files, vitest, manual check on both platforms.
Suggested split: commit/PR 1 = card paper size (steps 1-3), commit/PR 2 = rounded corners (step 4).
🧪 Test strategy
| Type | Scenario | File |
|---|---|---|
| Unit | getCardPageSize: landscape image -> 242.65 x 153.07, portrait -> swapped, rotation 90 -> swapped; isSinglePage('card') / ('full') true, ('a4') false; radius ratio ~0.059 |
app/utils/pdfPaper.test.ts (red first, mutation-checked) |
| Manual, native | Export a 2-sided card: 2 pages of 85.6 x 54 mm, image fitted, OCR text layer aligned, portrait scan gives a portrait page. Android + iOS | device / simulator |
| Manual, native | round_corners on card and on A4 2-up: white corners, no seam; page rotated 90 / 180 correct; preview matches export |
device / simulator |
| Manual | Document scanner app: no card entry, no rounded corners row |
device / simulator |
Kotlin, the iOS canvas drawing and the preview cannot run under Vitest (native imports): manual checks only.
Additional context
Related ideas from #439, tracked separately: remember PDF export settings per card; card-shaped camera frame for auto scan.
- 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
Difficulty 5/5 Over a week Newbie friendliness 52/100
ossappscollective/OSS-DocumentScanner#864 ·
Maintainers usually reply within 1 day
All issues in ossappscollective/OSS-DocumentScanner
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
uxlfoundation/oneDNN#6604 · 1 comment ·
Maintainers usually reply within 2 days
-
[Bug]: RoundToNearest truncates in plugins compiled with spcomp 1.13Possibly taken @fmu1337 claimed this today. OpenBug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
alliedmodders/sourcemod#2627 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
lballabio/QuantLib#3134 · 1 comment ·
Maintainers usually reply within 3 days
-
new issue
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
llvm/llvm-project#245835 ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 1/5 Under an hour Newbie friendliness 72/100
EchoTools/nevr-runtime#2823 ·
Maintainers usually reply within 1 day