feat: add PDF export functionality and test#110
Conversation
|
Thanks a lot for this contribution! Really solid work, the PDF export feature is cleanly implemented, well-structured, and easy to follow. I ran the tests for both high and default thresholds and they passed without issues. The code is tidy and the docstrings are clear and helpful. I also checked that fpdf is properly added to the requirements and the output PDF looks great, with all the expected metadata included. No changes to the existing API behaviour either, which is perfect. Happy to approve this. |
|
Hi @dj0409 thanks so much for this contribution, this is really valuable! I have a couple of questions
thanks! |
|
hey I'm happy to hear that it works, I saw also regarding the requirements, only fpdf==1.7.2 is necessary not both. And I just did the PR to the API repo thanks :) |
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.