pdflatex


Namepdflatex JSON
Version 0.1.3 PyPI version JSON
download
home_pagehttps://github.com/mbello/pdflatex
SummarySimple wrapper to calling pdflatex
upload_time2019-02-05 04:30:46
maintainermbello
docs_urlNone
authormbello
requires_python>=3.6,<4.0
license
keywords pdflatex pypdflatex latex to pdf using python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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:
1. The pdf file in a binary string;
2. The log file generated by pdflatex as text;
3. An instance of subprocess.CompleteProcess with the results of the pdflatex execution.

Also, **create_pdf** takes a few parameters:
1. 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;
2. keep_log_file: same thing, for the log file.
3. 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()
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mbello/pdflatex",
    "name": "pdflatex",
    "maintainer": "mbello",
    "docs_url": null,
    "requires_python": ">=3.6,<4.0",
    "maintainer_email": "mbello@users.noreply.github.com",
    "keywords": "pdflatex,pypdflatex,latex to pdf using python",
    "author": "mbello",
    "author_email": "mbello@users.noreply.github.com",
    "download_url": "https://files.pythonhosted.org/packages/ad/c8/4328fc20c2fcdc7db89b86203b93dd53889eba5b6260b8b499c47947c8be/pdflatex-0.1.3.tar.gz",
    "platform": "",
    "description": "# Overview\n\nThis is a simple module to execute pdflatex in an easy and clean way.\nThe pdflatex command line utility by default generates a lot of output and can create many files.\n\n## Instantiation\n\nThe PDFLaTeX class can be instantiated directly or through helpers:\n\n- **from_texfile(filename)**\n- **from_binarystring(binstr, jobname)**\n- **from_jinja2_template(jinja2_template, jobname = None, \\*\\*render_kwargs)**\n\njobname is any string that can be used to create a valid filename;\n\n\n## Examples:\n\nIn all the following examples, no files are left on the filesystem,\nunless requested with the *keep_pdf_file* and *keep_log_file* parameters\nto the *create_pdf* method.\n\n### Create PDF from .tex file\n\n    from pdflatex import PDFLaTeX\n\n    pdfl = PDFLaTeX.from_texfile('my_file.tex')\n    pdf, log, completed_process = pdfl.create_pdf(keep_pdf_file=True, keep_log_file=True)\n\nThe function **create_pdf** returns 3 results:\n1. The pdf file in a binary string;\n2. The log file generated by pdflatex as text;\n3. An instance of subprocess.CompleteProcess with the results of the pdflatex execution.\n\nAlso, **create_pdf** takes a few parameters:\n1. 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;\n2. keep_log_file: same thing, for the log file.\n3. env: a default ENV mapping for the execution of pdflatex. You probably want to skip this.\n\n\n### Create PDF from Jinja2 Template\n\n    import os\n    import pdflatex\n    import jinja2 \n    \n    env = pdflatex.JINJA2_ENV\n    env['loader'] = jinja2.FileSystemLoader(os.path.abspath('.'))\n    env = jinja2.Environment(**env)\n    template = env.get_template('jinja.tex')\n    pdfl = pdflatex.PDFLaTeX.from_jinja2_template(template, data='Hello world!')\n    pdf, log, cp = pdfl.create_pdf()\n\nQuite self explanatory, just note that pdflatex includes a dictionary\nJINJA2_ENV with a suggestion of environment parameters for you to use with\njinja2 and LaTeX. It os defined as:\n\n    JINJA2_ENV = {'block_start_string': '\\BLOCK{',\n                  'block_end_string': '}',\n                  'variable_start_string': '\\VAR{',\n                  'variable_end_string': '}',\n                  'comment_start_string': '\\#{',\n                  'comment_end_string': '}',\n                  'line_statement_prefix': '%%',\n                  'line_comment_prefix': '%#',\n                  'trim_blocks': True,\n                  'autoescape': False }\n\n\n### Create PDF file from binary string:\n\n    import pdflatex\n\n    with open('my_file.tex', 'rb') as f:\n        pdfl = pdflatex.PDFLaTeX.from_binarystring(f.read(), 'my_file')\n    pdf, log, cp = pdfl.create_pdf()",
    "bugtrack_url": null,
    "license": "",
    "summary": "Simple wrapper to calling pdflatex",
    "version": "0.1.3",
    "project_urls": {
        "Homepage": "https://github.com/mbello/pdflatex",
        "Repository": "https://github.com/mbello/pdflatex"
    },
    "split_keywords": [
        "pdflatex",
        "pypdflatex",
        "latex to pdf using python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c57d22617944ceff84c65a515a0a8f7d61386c7ea61a3c592313510525a207ae",
                "md5": "3e704c0ab2693bcd6a9c2aa2f59b428a",
                "sha256": "0e22bf240dd2dc2dd348686e5d259ff00af9ccc8bb1db481c38d03f29184e56e"
            },
            "downloads": -1,
            "filename": "pdflatex-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3e704c0ab2693bcd6a9c2aa2f59b428a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6,<4.0",
            "size": 8350,
            "upload_time": "2019-02-05T04:30:44",
            "upload_time_iso_8601": "2019-02-05T04:30:44.046962Z",
            "url": "https://files.pythonhosted.org/packages/c5/7d/22617944ceff84c65a515a0a8f7d61386c7ea61a3c592313510525a207ae/pdflatex-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "adc84328fc20c2fcdc7db89b86203b93dd53889eba5b6260b8b499c47947c8be",
                "md5": "11c941973e3133ae261d8215b3c1df43",
                "sha256": "b8109ff5a5b813e15d6a9e05b4c4c1ae3893b407ad1f8567ef5b89ec37a7aed5"
            },
            "downloads": -1,
            "filename": "pdflatex-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "11c941973e3133ae261d8215b3c1df43",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6,<4.0",
            "size": 4076,
            "upload_time": "2019-02-05T04:30:46",
            "upload_time_iso_8601": "2019-02-05T04:30:46.394041Z",
            "url": "https://files.pythonhosted.org/packages/ad/c8/4328fc20c2fcdc7db89b86203b93dd53889eba5b6260b8b499c47947c8be/pdflatex-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2019-02-05 04:30:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mbello",
    "github_project": "pdflatex",
    "github_not_found": true,
    "lcname": "pdflatex"
}
        
Elapsed time: 0.79785s