pydocmaker.backend.pdf_maker_tex

Attributes

log

_latex_compiler

_allowed_compilers

Functions

test_latex_compiler(compiler)

config_latex_compiler_scan()

config_latex_compiler_testset([verb])

config_latex_compiler_set(new_latex_compiler_str)

config_latex_compiler_get([verb])

setup()

zip_folder(folder_path)

_procrun(args[, verb, ignore_error])

make_pdf_from_tex(→ bytes)

Converts a LaTeX document to a PDF or a ZIP file containing the PDF and all attachments.

Module Contents

pydocmaker.backend.pdf_maker_tex.log
pydocmaker.backend.pdf_maker_tex.test_latex_compiler(compiler)
pydocmaker.backend.pdf_maker_tex._latex_compiler = None
pydocmaker.backend.pdf_maker_tex._allowed_compilers
pydocmaker.backend.pdf_maker_tex.config_latex_compiler_scan()
pydocmaker.backend.pdf_maker_tex.config_latex_compiler_testset(verb=1)
pydocmaker.backend.pdf_maker_tex.config_latex_compiler_set(new_latex_compiler_str)
pydocmaker.backend.pdf_maker_tex.config_latex_compiler_get(verb=0)
pydocmaker.backend.pdf_maker_tex.setup()
pydocmaker.backend.pdf_maker_tex.zip_folder(folder_path)
pydocmaker.backend.pdf_maker_tex._procrun(args, verb=0, ignore_error=False, **kwargs)
pydocmaker.backend.pdf_maker_tex.make_pdf_from_tex(input_latex_text, attachments_dc=None, docname='', out_format='pdf', base_dir=None, latex_compiler=None, n_times_make=None, verb=0, ignore_error=False) bytes

Converts a LaTeX document to a PDF or a ZIP file containing the PDF and all attachments.

Parameters:
  • input_latex_text (str or bytes) – The LaTeX document as a string or bytes.

  • attachments_dc (dict, optional) – A dictionary of attachments to include in the ZIP file. The keys are the filenames and the values are the file contents as bytes or strings. Defaults to an empty dictionary.

  • docname (str, optional) – The name of the output document. Defaults to a timestamp.

  • out_format (str, optional) – The format of the output. Either ‘pdf’ or ‘zip’. Defaults to ‘pdf’.

  • base_dir (str, optional) – The directory to use as the base directory for the temporary directory. Defaults to the system’s default temporary directory.

  • latex_compiler (str, optional) – The LaTeX compiler to use. Either ‘pdflatex’, ‘lualatex’, ‘xelatex’, or ‘pandoc’. If not specified, the function will try to use ‘pandoc’, ‘pdflatex’, ‘lualatex’, or ‘xelatex’ in that order.

  • n_times_make (int, optional) – The number of times to run the LaTeX compiler. Defaults to 1 for pandoc and 3 for al others.

  • verb (int, optional) – The verbosity level. If greater than 0, the function will print debug information. Defaults to 0.

  • ignore_error (bool, optional) – Whether to ignore errors during the LaTeX compilation. Defaults to False.

Returns:

The PDF document as bytes, or a ZIP file containing the PDF and all attachments as bytes.

Return type:

bytes

Raises:
  • ValueError – If the input_latex_text is not a string or bytes, or if the docname is not a string.

  • ValueError – If the latex_compiler is not ‘pdflatex’, ‘lualatex’, ‘xelatex’, or ‘pandoc’.

  • ValueError – If the out_format is not ‘pdf’ or ‘zip’.

  • AssertionError – If the attachments_dc contains invalid keys or values.