feat: add PDF export functionality and test #110
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces a new feature to generate PDF reports from matched questionnaire items using fpdf. The function generate_pdf_report() creates a structured and readable PDF summarizing matched question pairs across instruments, with optional threshold filtering and match score display.
The report includes:
Table-formatted matched question pairs with instrument names and question numbers.
Match percentage per pair.
A count of matched items in the header.
A configurable threshold to filter weaker matches.
A new test file tests/test_export_pdf_report.py was also added to validate the PDF export functionality and the requirements.txt where updated because it needs fpdf.
Fixes # (issue)
Not linked to a specific issue — this is a standalone feature contribution, since i implemented it in python, there is an issue in the harmony app which wants this feature tho ( this would be #53 then)
Type of change
Please delete options that are not relevant.
Testing
Tests were added in tests/test_export_pdf_report.py:
test_high_threshold_yields_no_matches: Verifies the report correctly shows 0 matches with a 99% threshold.
test_default_threshold_yields_some_matches: Verifies that matches appear with the default 50% threshold.
To run the tests:
pytest -q
Test Configuration
Checklist
requirements.txt,pyproject.tomland also in therequirements.txtin the API repoOptionally: feel free to paste your Discord username in this format:
discordapp.com/users/yourIDin your pull request description, then we can know to tag you in the Harmony Discord server when we announce the PR.