safe.utilities.printing module

Printing related utilities.

safe.utilities.printing.dpi_to_meters(dpi)[source]

Convert dots per inch (dpi) to dots per meters.

Parameters:dpi (int, float) – Dots per inch in the print / display medium.
Returns:dpi converted value.
Return type:int
safe.utilities.printing.mm_to_points(mm, dpi)[source]

Convert measurement in mm to one in points.

Parameters:
  • mm (int, float) – A distance in millimeters.
  • dpi (int, float) – Dots per inch to use for the calculation (based on in the print / display medium).
Returns:

mm converted value as points.

Return type:

int, float

safe.utilities.printing.points_to_mm(points, dpi)[source]

Convert measurement in points to one in mm.

Parameters:
  • points (int) – A distance in points.
  • dpi (int) – Dots per inch to use for the calculation (based on in the print / display medium).
Returns:

points converted value as mm.

Return type:

int

safe.utilities.printing.setup_printer(filename, resolution=300, page_height=297, page_width=210, page_margin=None)[source]

Create a QPrinter instance defaulted to print to an A4 portrait pdf.

Parameters:
  • filename (str) – Filename for the pdf print device.
  • resolution (int) – Resolution (in dpi) for the output.
  • page_height (int) – Height of the page in mm.
  • page_width (int) – Width of the page in mm.
  • page_margin (list) – Page margin in mm in form [left, top, right, bottom].