How to remove margins in pdfs #99

Closed
opened 2021-05-12 06:31:36 +00:00 by MMCMA · 3 comments

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')) ```
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?
Author

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!
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 2021-05-12 11:44:28 +00:00
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
No description provided.