Open mulla028 opened 3 weeks ago
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!
@Lucas-C Thank you for your feedback, some things were pretty new to me. Thank you for your patience. Hopefully, this time code follows your requirements π
@Lucas-C is my problem comes with my code styling?
@Lucas-C is my problem comes with my code styling?
No, it's OK π
I only see a couple of blocking points:
FAILED tests/test_x2pdf.py::test_x2pdf_with_format - ValueError: Invalid or unsupported page format provided: Letter
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 @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.
Closes #63
Summary
This pull request introduces the
--format
option to thex2pdf
command 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.,210x297
mm). 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
--format
option to thex2pdf
command with a default value ofA4-portrait
.x2pdf.py
get_page_size
function to map standard format names to dimensions or parse custom dimensions (e.g.,210x297
).image_to_pdf
function to center and scale images according to the specified page size.main
function to acceptformat
as a parameter and apply the selected page size to each PDF page.Tests
test_x2pdf.py
--format
option with various formats, including standard (Letter
,A4-portrait
,A4-landscape
) and custom dimensions (210x297
).Verification Steps
pdfly x2pdf --help
to verify that--format
is listed in the options.x2pdf
with standard and custom formats: