How to remove margins in pdfs #99

Closed
opened 3 years ago by MMCMA · 3 comments
MMCMA commented 3 years ago

I struggle to understand how to remove white margins while converting to pdf. I have A4 scans and I would like to convert them without margin. How can I do this? My current code looks as follows. Thank you.

    a4 = (img2pdf.mm_to_pt(210), img2pdf.mm_to_pt(297))
    layout_fun = img2pdf.get_layout_fun(a4,
                                        fit=img2pdf.FitMode.exact ,
                                        auto_orient=True)
    with open(file_path, "wb") as f:
        f.write(img2pdf.convert(images_to_convert,
                                layout_fun=layout_fun,
                                pagesize='a4'))
I struggle to understand how to remove white margins while converting to pdf. I have A4 scans and I would like to convert them without margin. How can I do this? My current code looks as follows. Thank you. ``` a4 = (img2pdf.mm_to_pt(210), img2pdf.mm_to_pt(297)) layout_fun = img2pdf.get_layout_fun(a4, fit=img2pdf.FitMode.exact , auto_orient=True) with open(file_path, "wb") as f: f.write(img2pdf.convert(images_to_convert, layout_fun=layout_fun, pagesize='a4')) ```
josch commented 3 years ago
Owner

I do not yet understand what you mean by "white margins". If your input images are of A4 size and have the right dpi set, then the created pages will also be A4. Also, the convert() function does not have a pagesize argument. Maybe it helps if you post an example image here so that I can see the problem you have?

I do not yet understand what you mean by "white margins". If your input images are of A4 size and have the right dpi set, then the created pages will also be A4. Also, the convert() function does not have a pagesize argument. Maybe it helps if you post an example image here so that I can see the problem you have?
MMCMA commented 3 years ago
Poster

Thanks for the reply. I just noticed that the original document was the root cause, sorry for the confusion. Seems to work perfectly, great repo!

Thanks for the reply. I just noticed that the original document was the root cause, sorry for the confusion. Seems to work perfectly, great repo!
josch commented 3 years ago
Owner

Please close this issue once you think that the problem has been resolved.

Please close this issue once you think that the problem has been resolved.
MMCMA closed this issue 3 years ago
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: josch/img2pdf#99
Loading…
There is no content yet.