-
Notifications
You must be signed in to change notification settings - Fork 45
ENH: Add --format Option for Custom Page Sizes in x2pdf Command
#65
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
base: main
Are you sure you want to change the base?
Conversation
| if format_option != "invalid-format": | ||
| assert exit_code == 0, captured | ||
| assert captured.out == "" | ||
| assert output.exists() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be interesting to also validate the resulting pages dimensions.
This can be checked with pdfly pagemeta $pdf_filepath $page_index
Or using the underlying pypdf library: PdfReader(pdf: Path).mediabox/.cropbox/.artbox/.bleedbox
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you did not handle that feedback comment @mulla028 🙂
Lucas-C
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job tackling this issue! 👍
Thank you for your contribution 🙂
I made a few comments as feedback.
Thank you for your feedback! I will do my best to make all these changes 🙂 |
|
@Lucas-C I tried to make all the requested changes. Review please, and let me know if you noticed any issues! |
…non-zero code and adjusting success message if issue occur.
|
@Lucas-C |
|
@Lucas-C is my problem comes with my code styling? |
| elif orientation == "portrait": | ||
| return (width, height) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| elif orientation == "portrait": | |
| return (width, height) |
Just a minor code improvement suggestion.
This change is not mandatory before merging this PR.
No, it's OK 🙂 I only see a couple of blocking points:
You should be able to reproduce the problem by executing the unit tests on your own computer 🙂 |
|
Hi @mulla028 🙂 Just to get a quick update: do you still want to implement this feature? |
Hi! Yes, I just had to do a lot of work for school. I am gonna finish implementing this issue by the end of this week. |
|
Hi @mulla028 I'm sorry to ask again, but it has been 2 weeks, an another contributor has submitted a PR for a several feature: #77 Do you think that you will have some time in the near future to finish implementing this? Else we could consider having someone else finishing the work on this PR, either me, @pastor-robert or another contributor 🙂 |
--format Option for Custom Page Sizes in x2pdf Command--format Option for Custom Page Sizes in x2pdf Command
Closes #63
Summary
This pull request introduces the
--formatoption to thex2pdfcommand inpdfly, allowing users to specify custom page sizes for PDF output. The option supports standard formats such asLetter,A4-portrait, andA4-landscape, as well as custom dimensions (e.g.,210x297mm). This enhancement provides flexibility for generating PDFs with various page sizes, scaling and centering images to fit each specified format.Changes
Code Updates
cli.py--formatoption to thex2pdfcommand with a default value ofA4-portrait.x2pdf.pyget_page_sizefunction to map standard format names to dimensions or parse custom dimensions (e.g.,210x297).image_to_pdffunction to center and scale images according to the specified page size.mainfunction to acceptformatas a parameter and apply the selected page size to each PDF page.Tests
test_x2pdf.py--formatoption with various formats, including standard (Letter,A4-portrait,A4-landscape) and custom dimensions (210x297).Verification Steps
pdfly x2pdf --helpto verify that--formatis listed in the options.x2pdfwith standard and custom formats: