Skip to content

Introduce PdfExportService and platform interfaces#3758

Open
andreia-ferreira wants to merge 14 commits into
masterfrom
andreia/3754/pdf-renderers
Open

Introduce PdfExportService and platform interfaces#3758
andreia-ferreira wants to merge 14 commits into
masterfrom
andreia/3754/pdf-renderers

Conversation

@andreia-ferreira
Copy link
Copy Markdown
Collaborator

@andreia-ferreira andreia-ferreira commented May 28, 2026

Towards #3715

Introduces the scaffolding for PDF export of submission data. This is platform-independent and has the PdfExportService as entry point. The provider/renderer/launcher interfaces will be implemented on the platform level on the next PR. This new code is part of a new KMP module :feature:pdf

Additionally, as a small cleanup, removed the jvm from the core:ui gradle config because otherwise all expect/actual logic would have to be also implemented on jvmMain. Also added androidLibrary target to core:testing so that the fake testing classes are possible to be used by modules that contain that target

This introduces no functionality changes.

@shobhitagarwal1612 PTAL?

@andreia-ferreira andreia-ferreira changed the title Andreia/3754/pdf renderers Introduce PdfExportService and platform interfaces May 28, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 29, 2026

Codecov Report

❌ Patch coverage is 80.00000% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.11%. Comparing base (e61a20d) to head (c686435).

Files with missing lines Patch % Lines
...id/ui/home/mapcontainer/jobs/ShareLocationModal.kt 69.23% 3 Missing and 1 partial ⚠️
...datacollection/DataSubmissionConfirmationScreen.kt 76.92% 2 Missing and 1 partial ⚠️
.../ui/datacollection/DataCollectionScreenPreviews.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3758      +/-   ##
============================================
+ Coverage     68.06%   68.11%   +0.05%     
+ Complexity     1612     1610       -2     
============================================
  Files           369      369              
  Lines          9534     9529       -5     
  Branches       1244     1246       +2     
============================================
+ Hits           6489     6491       +2     
+ Misses         2377     2368       -9     
- Partials        668      670       +2     
Files with missing lines Coverage Δ
...tform/domain/model/locationofinterest/LoiReport.kt 100.00% <100.00%> (ø)
...undplatform/domain/usecases/GetLoiReportUseCase.kt 89.58% <100.00%> (+0.45%) ⬆️
.../ui/datacollection/DataCollectionScreenPreviews.kt 0.00% <0.00%> (ø)
...datacollection/DataSubmissionConfirmationScreen.kt 90.32% <76.92%> (-1.26%) ⬇️
...id/ui/home/mapcontainer/jobs/ShareLocationModal.kt 66.12% <69.23%> (+2.06%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

val images = imageProvider.load(request.qrContent, request.document.photoFilenames())
try {
renderer.render(request.document, images, path)
} finally {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If renderer.render() throws an exception (e.g. out of memory, disk full, etc.), a partially written or corrupted 0-byte file might be left on the disk. To prevent opening/sharing broken PDFs, please consider catching exceptions during rendering and delete the corrupted file. Then re-throw the exception so it can be handled upstream

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for catching this. Added the exception handling 👍

Comment on lines +62 to +63
.map { it.filter(::isSafeFileChar) }
.filter { it.isNotBlank() }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this work for other locales (e.g. japanese or arabic characters)?

Copy link
Copy Markdown
Collaborator Author

@andreia-ferreira andreia-ferreira Jun 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, this would not work. I updated it so now characters from all languages are preserved

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.

2 participants