Metadata-Version: 2.1
Name: django-pikpdf
Version: 0.3.1
Summary: A Django app to convert html to pdf
Home-page: https://www.pikutis.lt/
Author: Tadas Pikutis
Author-email: tadas@pikutis.lt
License: MIT
Platform: UNKNOWN
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 4.2
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE


# pikpdf - propper html to pdf generator

django-pikpdf is a Django app to generate pdfs from html templates.
This app will capture the html from a template and convert it to a pdf file 
with all styles in tact.

Detailed documentation is in the "docs" directory.

## Quick start


1. Add "django-pikpdf" to your INSTALLED_APPS setting like this::

    INSTALLED_APPS = [
        ...,
        "django-pikpdf",
    ]

2. Add the following settings to your settings.py:
    
    ```PIKUTIS_API_KEY=os.environ.get("PIKUTIS_API_KEY", None) # can be obtained from https://www.pikutis.lt for free
      SITE_URL = os.environ.get("SITE_URL", "https://www.pikutis.lt") # your website url```
    
2. Include conversion method get_document_pdf_response as so:

    ```from django_pikpdf.utils import get_document_pdf_response```

3. Use the method to convert your html to pdf and return a response:

    ```html_content = render_to_string("my_template.html", context)
    file_name = "my_pdf_file"
    http_response, file_bytes = get_document_pdf_response(html_content, file_name)
    # HTTP response is a response object which will promt end user to download the file
    # file_bytes is the pdf file buffer, which you can i.e. attach to email
    return http_response

That's it! You can now convert your html to pdf and return it as a response.

