cropper submodule¶
This module contains wrappers over pyPdf, which provides high level API for cropping PDF files.
Note
All sizes used in this module should be in millimeters.
API¶
-
pdfcropper.cropper.POINT_MM= 0.35277777777777775¶ 1pt = inch/72, 1 inch = 25.4 mm
-
pdfcropper.cropper.get_width_height(page)[source]¶ Return width and height of the page.
Parameters: page (obj) – PdfFileReader.pagesinstance.Returns: (width, height)as float, in millimeters.Return type: tuple
-
pdfcropper.cropper.crop_page(page, left, right, top, bottom)[source]¶ Crop page to size given by left, right, top and bottom.
Parameters: Warning
This functions modifies the page reference!
Returns: Modified page object. Return type: obj
-
pdfcropper.cropper.crop_all(pdf, left, right, top, bottom, remove=[])[source]¶ Crop all pages in pdf. Remove pages specified by remove.
Parameters: - pdf (obj) –
pyPdfPdfFileReaderobject. - left (int) – Cut X millimeters from left.
- right (int) – Cut X millimeters from right.
- top (int) – Cut X millimeters from top.
- bottom (int) – Cut X millimeters from bottom.
- remove (list/tuple, default []) – List of integers. As the function iterates thru the pages in pdf, indexes of the pages which matchs those in remove will be skipped.
Returns: PdfFileWriterinstance, with modified pages.Return type: obj
- pdf (obj) –
-
pdfcropper.cropper.crop_differently(pdf, even_vector, odd_vector, remove=[])[source]¶ Crop pdf even pages by even_vector and odd pages by odd_vector. Remove pages specified by remove.
Parameters: - pdf (obj) –
pyPdfPdfFileReaderobject. - even_vector (list) – List of coordinates to which all even pages will
be cropped.
[Left, Right, Top, Bottom]. - odd_vector (list) – List of coordinates to which all odd pages will
be cropped.
[Left, Right, Top, Bottom]. - remove (list/tuple, default []) – List of integers. As the function iterates thru the pages in pdf, indexes of the pages which matchs those in remove will be skipped.
Returns: PdfFileWriterinstance, with modified pages.Return type: obj
- pdf (obj) –
-
pdfcropper.cropper.remove_pages(pdf, remove)[source]¶ Remove pages specified in vector remove.
Parameters: - pdf (obj) –
pyPdfPdfFileReaderobject. - remove (list/tuple, default []) – List of integers. As the function iterates thru the pages in pdf, indexes of the pages which matchs those in remove will be skipped.
Returns: PdfFileWriterinstance, with modified pages.Return type: obj
- pdf (obj) –