Overview
This is a simple module to execute pdflatex in an easy and clean way. The pdflatex command line utility by default generates a lot of output and can create many files.
Instantiation
The PDFLaTeX class can be instantiated directly or through helpers:
- from_texfile(filename)
- from_binarystring(binstr, jobname)
- from_jinja2_template(jinja2_template, jobname = None, **render_kwargs)
jobname is any string that can be used to create a valid filename;
Examples:
In all the following examples, no files are left on the filesystem, unless requested with the keep_pdf_file and keep_log_file parameters to the create_pdf method.
Create PDF from .tex file
from pdflatex import PDFLaTeX
pdfl = PDFLaTeX.from_texfile('my_file.tex')
pdf, log, completed_process = pdfl.create_pdf(keep_pdf_file=True, keep_log_file=True)
The function create_pdf returns 3 results:
- The pdf file in a binary string;
- The log file generated by pdflatex as text;
- An instance of subprocess.CompleteProcess with the results of the pdflatex execution.
Also, create_pdf takes a few parameters:
- keep_pdf_file: an optional boolean. Default to False. If True a pdf file is maintained. Its location and name depends on the value of the -output-directory and -jobname parameters. It is also derived from the tex filename or the jinja2 template filename if no parameter is given;
- keep_log_file: same thing, for the log file.
- env: a default ENV mapping for the execution of pdflatex. You probably want to skip this.
Create PDF from Jinja2 Template
import os
import pdflatex
import jinja2
env = pdflatex.JINJA2_ENV
env['loader'] = jinja2.FileSystemLoader(os.path.abspath('.'))
env = jinja2.Environment(**env)
template = env.get_template('jinja.tex')
pdfl = pdflatex.PDFLaTeX.from_jinja2_template(template, data='Hello world!')
pdf, log, cp = pdfl.create_pdf()
Quite self explanatory, just note that pdflatex includes a dictionary JINJA2_ENV with a suggestion of environment parameters for you to use with jinja2 and LaTeX. It os defined as:
JINJA2_ENV = {'block_start_string': '\BLOCK{',
'block_end_string': '}',
'variable_start_string': '\VAR{',
'variable_end_string': '}',
'comment_start_string': '\#{',
'comment_end_string': '}',
'line_statement_prefix': '%%',
'line_comment_prefix': '%#',
'trim_blocks': True,
'autoescape': False }
Create PDF file from binary string:
import pdflatex
with open('my_file.tex', 'rb') as f:
pdfl = pdflatex.PDFLaTeX.from_binarystring(f.read(), 'my_file')
pdf, log, cp = pdfl.create_pdf()
Metadata
Release files for pdflatex 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pdflatex-0.1.3.tar.gz | 4.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pdflatex-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.4 kB
Release files / pdflatex-0.1.3.tar.gz
| Download URL | pdflatex-0.1.3.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b8109ff5a5b813e15d6a9e05b4c4c1ae3893b407ad1f8567ef5b89ec37a7aed5
|
|
BLAKE2b-256 checksum How to use checksums |
adc84328fc20c2fcdc7db89b86203b93dd53889eba5b6260b8b499c47947c8be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/0.12.11 CPython/3.6.7 Linux/4.18.0-13-generic
|
Release files / pdflatex-0.1.3-py3-none-any.whl
| Download URL | pdflatex-0.1.3-py3-none-any.whl |
|---|---|
| Size | 8.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0e22bf240dd2dc2dd348686e5d259ff00af9ccc8bb1db481c38d03f29184e56e
|
|
BLAKE2b-256 checksum How to use checksums |
c57d22617944ceff84c65a515a0a8f7d61386c7ea61a3c592313510525a207ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/0.12.11 CPython/3.6.7 Linux/4.18.0-13-generic
|
Security for pdflatex 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.