pygacity.util.pdfutils module

PDF utility functions for pygacity

pygacity.util.pdfutils.bundle_pdfs(pdf_paths: list, output_path, two_sided: bool = False)[source]

Merge a list of PDF files into a single bundle PDF.

Parameters:
  • pdf_paths (list of str or Path) – Ordered list of PDF files to include in the bundle.

  • output_path (str or Path) – Destination path for the merged bundle PDF.

  • two_sided (bool, optional) – If True, pad each exam to an even page count by appending a blank page when the exam has an odd number of pages. This ensures the first page of every exam falls on a right-hand (odd) sheet side when printed double-sided (default: False).

pygacity.util.pdfutils.bundle_subcommand(args)[source]

CLI subcommand: bundle student exam PDFs found in a build directory.

Student PDFs are identified by excluding files whose names contain _soln, answerset, or bundle. They are sorted by modification time (build order) before being chunked.

pygacity.util.pdfutils.combine_pdfs(args)[source]
pygacity.util.pdfutils.duplicate_last_page(input_pdf, output_pdf)[source]

Duplicate the last page of a PDF document and append it to the end.

Parameters:
  • input_pdf – Path to the input PDF file

  • output_pdf – Path to save the modified PDF file