Source code for uw.local.teaching.db.pdf

"""PDF processing.

This module implements additional PDF processing routines.
"""

from subprocess import Popen, PIPE

[docs]def embed_fonts (pdf): """Embed all fonts in the given PDF document. :param pdf: The PDF document. :return: A 2-tuple consisting of a boolean success indication and either the PDF with fonts embedded or the error report from the sub-process. """ pdftopdf_process = Popen (['/home/odyssey/bin/print-embed-fonts', '-', '-'], stdin=PIPE, stdout=PIPE, stderr=PIPE) stdoutdata, stderrdata = pdftopdf_process.communicate (pdf) result = pdftopdf_process.wait () if result != 0: return False, stderrdata return True, stdoutdata