Skip to main content

A fast PDF generation package using Handlebars templates

Project description

Fast PDF Generator

Fast PDF Generator is a Python package that allows you to generate PDF files using Handlebars templates quickly. It provides a simple and efficient way to compile Handlebars templates and convert them into PDF documents.

Features

  • Handlebars Template Compilation: Compile Handlebars templates to HTML strings.
  • PDF Generation: Generate PDF files from compiled HTML content.
  • Path Handling: Support for both absolute and relative file paths on Linux, macOS, and Windows.

Installation

You can install the fast_pdf_gen package using pip:

pip install fast_pdf_gen

Usage

from fast_pdf_gen import compile_handlebars_template, generate_pdf

# Handlebars Template Compilation
template_key = 'template1'
template_path_or_string = 'path/to/template.html'  # Or a template string
context = {'variable': 'value'}
compiled_template = compile_handlebars_template(template_key, template_path_or_string, context=context)
#Options
pdf_options = {
    'format': 'A3',
    'margin': {
       'top': '10mm',
       'right': '10mm',
       'bottom': '10mm',
       'left': '10mm'
    }
}

# PDF Generation
output_path = 'output.pdf'
generate_pdf(template_key, template_string, output_path, context=context, pdf_options=pdf_options)

Options

  • template_key (str): Unique identifier for the template.
  • template_path_or_string (str): Path to the HTML template file or a template string.
  • compiled_template (str): Compiled HTML content obtained from compile_handlebars_template.
  • output_path (str): Path where the generated PDF will be saved.
  • context (optional, dict): Dictionary containing variables to be substituted in the Handlebars template.

Contributing

  1. Fork the repository and clone it locally.
  2. Create a new branch for your feature: git checkout -b feature-name.
  3. Make your changes and commit them: git commit -m 'Add new feature'.
  4. Push to the branch: git push origin feature-name.
  5. Create a pull request on GitHub.

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fast_pdf_gen-1.0.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file fast_pdf_gen-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: fast_pdf_gen-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for fast_pdf_gen-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 abc57bbf977c1a36acc928b5f6e6721e350e1eb56ec578507914aefc580a197b
MD5 cf0a1d2e8d36cbd10a7bfaf9904a04e6
BLAKE2b-256 98cfb0ad7f175fd49df9a2dc52bf8aef2adf28beedbde0ae1dc105777eda7624

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page