skm_tools.pdf_utils

Crop PDF files and combine them into one, with captions (e.g. exported network views).

Requires the pdf extra (pip install skm-tools[pdf]). To export the networks of a Cytoscape collection as cropped PDFs, see skm_tools.cytoscape_utils.export_collection() (format="PDF", crop=True).

Attributes

logger

Functions

crop_pdf(path[, out, margins])

Crop the margins of a PDF (with pdfCropMargins).

combine_pdfs(files, filename[, captions, font_size, font])

Combine PDFs into one, a page each (the first page of each file), with captions.

Module Contents

skm_tools.pdf_utils.logger
skm_tools.pdf_utils.crop_pdf(path, out=None, margins=None)

Crop the margins of a PDF (with pdfCropMargins).

Parameters:
  • path (str or pathlib.Path) – PDF to crop.

  • out (str or pathlib.Path, optional) – File to write (default: replace path).

  • margins (tuple of float, optional) – Space to add after cropping (left, bottom, right, top), in points, e.g. (0, 20, 0, 0) for a caption below. Default: none.

Returns:

The cropped file.

Return type:

pathlib.Path

skm_tools.pdf_utils.combine_pdfs(files, filename, captions=None, font_size=20, font='Helvetica')

Combine PDFs into one, a page each (the first page of each file), with captions.

Parameters:
  • files (iterable of str or pathlib.Path) – PDFs to combine, in order (e.g. from skm_tools.cytoscape_utils.export_collection()). They are not changed.

  • filename (str or pathlib.Path) – PDF file to write (overwritten if it exists).

  • captions (list of str, optional) – A caption for each page, written below it (default: none).

  • font_size (float) – Caption font size (default 20).

  • font (str) – Caption font (default Helvetica; the default font if unavailable).

Returns:

filename.

Return type:

pathlib.Path