Skip to content

Refactor OpenPDF for Improved Code Maintainability: Encapsulation, Factory Method, and Utility Class Extraction #1241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

samruddhithakor
Copy link
Contributor

@samruddhithakor samruddhithakor commented Nov 27, 2024

Description of the new Feature/Bugfix

This pull request improves maintainability and reduces redundancy in the OpenPDF project through the following refactorings:

  1. Pull-Up Method: Moved setTemplateData to the Image superclass to handle PdfTemplate initialization generically and reduce duplication.
  2. Factory Method: Added createFromTemplate in Image for streamlined and centralized creation of Image objects from PdfTemplate.
  3. Extract Class: Extracted processParameters logic from ImgWMF to a new utility class, WMFProcessor, and introduced WMFData to encapsulate parameters. Simplified ImgWMF to delegate responsibilities to WMFProcessor.

Related Issue: #

Unit-Tests for the new Feature/Bugfix

  • Added tests for WMFProcessor to validate processParameters.
  • Updated tests for createFromTemplate.

Compatibilities Issues

No breaking changes. Refactored code maintains backward compatibility.

Your real name

Samruddhi Dharmeshkumar Thakor

Testing details

Verified WMFProcessor for correct parameter processing.
Tested createFromTemplate for proper initialization of Image objects.
Ran all existing tests to confirm no regressions.

Copy link

Copy link

@andreasrosdal andreasrosdal merged commit 229ba95 into LibrePDF:master May 20, 2025
4 checks passed
andreasrosdal added a commit that referenced this pull request May 20, 2025
…tion, Factory Method, and Utility Class Extraction (#1241)"

This reverts commit 229ba95.
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