gws.lib.pdf

PDF utilities.

Source code: gws.lib.pdf

Package Contents

gws.lib.pdf.concat(paths: list[str], out_path: str) str

Concatenate multiple pdfs into one.

Parameters:
  • paths – Paths to the pdfs.

  • out_path – Path to the output pdf.

Returns:

Path to the concatenated pdf.

gws.lib.pdf.overlay(a_path: str, b_path: str, out_path: str) str

Overlay two pdfs page-wise.

Parameters:
  • a_path – Path to pdf a.

  • b_path – Path to pdf b, which will be placed on top.

  • out_path – Path to the output pdf.

Returns:

Path to the output pdf.

gws.lib.pdf.page_count(path: str) int

Returns the amount of pages for a given pdf.

Parameters:

path – Path to the pdf.

gws.lib.pdf.to_image_path(in_path: str, out_path: str, size: gws.Size, mime: str = gws.lib.mime.PNG, page: int = 1) str

Convert a pdf to an image.

Parameters:
  • in_path – Path to the input pdf.

  • out_path – Path to the output image.

  • size – Size of the output image.

  • mime – Mime type of the output image. Must be either PNG or JPEG.

  • page – Page number to convert (1-indexed). Defaults to 1.

Returns:

Path to the output image.