Skip to content

Add common layout components for PDF#3782

Open
andreia-ferreira wants to merge 2 commits into
masterfrom
andreia/3739/layout
Open

Add common layout components for PDF#3782
andreia-ferreira wants to merge 2 commits into
masterfrom
andreia/3739/layout

Conversation

@andreia-ferreira

Copy link
Copy Markdown
Collaborator

Towards #3715

(Split from #3774)
This PR focuses on adding the building blocks for the PDF document: PageHeaderLayout (to display the survey name, job and date+time at the top), PageFooterLayout (to display the data collector information and the page number at the bottom), QrBlockLayout (to display the QR code embedding the geometry), TableLayout (with all the submission data) and their unit tests.

It also adds the following helpers:

  • PdfConfig for dimensions and margins
  • PdfGeometry for utilities and classes which handle calculations and measurements

@shobhitagarwal1612 PTAL?

@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.43%. Comparing base (b8ccfab) to head (260bf8e).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3782      +/-   ##
============================================
+ Coverage     66.14%   66.43%   +0.29%     
- Complexity     1660     1683      +23     
============================================
  Files           386      391       +5     
  Lines         10039    10129      +90     
  Branches       1288     1292       +4     
============================================
+ Hits           6640     6729      +89     
- Misses         2722     2723       +1     
  Partials        677      677              
Files with missing lines Coverage Δ
...g/groundplatform/feature/pdf/render/PdfGeometry.kt 100.00% <100.00%> (ø)
.../feature/pdf/render/components/PageFooterLayout.kt 100.00% <100.00%> (ø)
.../feature/pdf/render/components/PageHeaderLayout.kt 100.00% <100.00%> (ø)
...orm/feature/pdf/render/components/QrBlockLayout.kt 100.00% <100.00%> (ø)
...tform/feature/pdf/render/components/TableLayout.kt 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@shobhitagarwal1612 shobhitagarwal1612 left a comment

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.

Regarding the package structure, right now PageHeaderLayout, TableLayout, etc live in components package. Since components usually implies actual UI rendering code (like @Composable functions), and these classes are purely math models, would it make more sense to move these classes one level up (or maybe org.groundplatform.feature.pdf.render.layout or model)?

return maxOf(leftTextHeight, rightTextHeight + imageHeight + imageSpacing) + 2 * CELL_PADDING
}

fun getRow(

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.

Since this includes both the top and bottom borders for every row, would it cause rendering of a line twice? Would it be safer to only draw the bottom border per row or does the rendering would take care of deduplication?

*
* All measurements are in PDF points (1/72 inch).
*/
internal object PdfConfig {

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.

Please consider adding ktdoc for these constants. Also, there is a mix of Int and Float in here. Would converting them to Float be easier down the line?

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