django-persian-pdf


Namedjango-persian-pdf JSON
Version 0.0.5 PyPI version JSON
download
home_pageNone
SummaryDjango class based views to generate pdf files using html or latex template.
upload_time2024-04-18 07:54:27
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT
keywords pdf django persian xelatex
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Django Persian PDF
=========================

Django Persian PDF is a set of class based views allowing you to generate PDF reports
using html or latex templates.
Django Persian PDF under the hood uses two compiler to render template
and build the actual pdf file:
-  Xelatex
-  Google Chrome

Using this approach avoids regular overhead for parsing html tags, improving overall
response time and memory usage when generating large pdf files.
Django Persian PDF follows django class based views and base on the compiler provide 4 generic view classes.
The only difference is that these classes render their associated template and return a pdf file as response.
Just like django views you can pass queryset or make context to be used in template.
Here are the view classes available in `django_persian_pdf`:

-  `ChromePDFTemplateView` is an extension of django `TemplateView` which uses chrome and .html template to generate pdf file.
-  `ChromePDFDetailView` is an extension of django `DetailView` which uses chrome and .html template  to generate pdf file.
-  `LatexPDFTemplateView` is an extension of django `TemplateView` which uses latex and .tex template to generate pdf file.
-  `LatexPDFDetailView` is an extension of django `DetailView` which uses latex to and .tex template to generate pdf file.

Status
------

.. image:: https://github.com/bindruid/django-persian-pdf/workflows/Test/badge.svg?branch=master
   :target: https://github.com/bindruid/django-persian-pdf/actions

.. image:: https://img.shields.io/pypi/v/django-persian-pdf.svg
   :target: https://pypi.python.org/pypi/django-persian-pdf

.. image:: https://img.shields.io/pypi/pyversions/django-persian-pdf.svg
   :target: https://pypi.org/project/django-persian-pdf

.. image:: https://img.shields.io/pypi/djversions/django-persian-pdf.svg
   :target: https://pypi.org/project/django-persian-pdf/

Dependencies
------------

-  Django >= 3.2
-  Google Chrome Stable
-  xelatex

Install
-------

.. code-block:: bash

   pip install django-persian-pdf

Usage
-----

0. Make sure you have installed either `chrome_stable_` or `xelatex` on your machine.

1. Edit settings.py and add `django_persian_pdf` to your `INSTALLED_APPS`.

2. Inherit your views from appropriate Template or Detail view classes.

.. code-block:: python

    from django_persian_pdf import views

    class TemplatePrint(views.ChromePDFTemplateView):
        template_name = 'payment_reports.html'

        def get_context_data(self, **kwargs):
            context = super().get_context_data()
            context['payments'] = Payments.objects.all()
            return context

    class DetailPrint(views.ChromePDFDetailView):
        template_name = 'payment_detail.html'
        queryset = Payments.objects.all()


.. code-block:: python

    from django_persian_pdf import views

    class TemplatePrint(views.LatexPDFTemplateView):
        template_name = 'payment_reports.tex'

        def get_context_data(self, **kwargs):
            context = super().get_context_data()
            context['payments'] = Payments.objects.all()
            return context

    class DetailPrint(views.LatexPDFDetailView):
        template_name = 'payment_detail.tex'
        queryset = Payments.objects.all()

3. Using latex template for persian requires you to have installed your persian fonts in home.

.. code-block:: bash


   mkdir -p ~/.fonts
   cp /path_to_fonts/Vazirmatn.ttf ~/.fonts/
   fc-cache -f -v

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "django-persian-pdf",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "Ali Abharya <abharya.dev@gmail.com>",
    "keywords": "pdf, django, persian, xelatex",
    "author": null,
    "author_email": "Ali Abharya <abharya.dev@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/4d/d3/32db463fc3e31e4036a07370c4fef2490d994d8e5f162c0ecf34a540e982/django_persian_pdf-0.0.5.tar.gz",
    "platform": null,
    "description": "Django Persian PDF\n=========================\n\nDjango Persian PDF is a set of class based views allowing you to generate PDF reports\nusing html or latex templates.\nDjango Persian PDF under the hood uses two compiler to render template\nand build the actual pdf file:\n-  Xelatex\n-  Google Chrome\n\nUsing this approach avoids regular overhead for parsing html tags, improving overall\nresponse time and memory usage when generating large pdf files.\nDjango Persian PDF follows django class based views and base on the compiler provide 4 generic view classes.\nThe only difference is that these classes render their associated template and return a pdf file as response.\nJust like django views you can pass queryset or make context to be used in template.\nHere are the view classes available in `django_persian_pdf`:\n\n-  `ChromePDFTemplateView` is an extension of django `TemplateView` which uses chrome and .html template to generate pdf file.\n-  `ChromePDFDetailView` is an extension of django `DetailView` which uses chrome and .html template  to generate pdf file.\n-  `LatexPDFTemplateView` is an extension of django `TemplateView` which uses latex and .tex template to generate pdf file.\n-  `LatexPDFDetailView` is an extension of django `DetailView` which uses latex to and .tex template to generate pdf file.\n\nStatus\n------\n\n.. image:: https://github.com/bindruid/django-persian-pdf/workflows/Test/badge.svg?branch=master\n   :target: https://github.com/bindruid/django-persian-pdf/actions\n\n.. image:: https://img.shields.io/pypi/v/django-persian-pdf.svg\n   :target: https://pypi.python.org/pypi/django-persian-pdf\n\n.. image:: https://img.shields.io/pypi/pyversions/django-persian-pdf.svg\n   :target: https://pypi.org/project/django-persian-pdf\n\n.. image:: https://img.shields.io/pypi/djversions/django-persian-pdf.svg\n   :target: https://pypi.org/project/django-persian-pdf/\n\nDependencies\n------------\n\n-  Django >= 3.2\n-  Google Chrome Stable\n-  xelatex\n\nInstall\n-------\n\n.. code-block:: bash\n\n   pip install django-persian-pdf\n\nUsage\n-----\n\n0. Make sure you have installed either `chrome_stable_` or `xelatex` on your machine.\n\n1. Edit settings.py and add `django_persian_pdf` to your `INSTALLED_APPS`.\n\n2. Inherit your views from appropriate Template or Detail view classes.\n\n.. code-block:: python\n\n    from django_persian_pdf import views\n\n    class TemplatePrint(views.ChromePDFTemplateView):\n        template_name = 'payment_reports.html'\n\n        def get_context_data(self, **kwargs):\n            context = super().get_context_data()\n            context['payments'] = Payments.objects.all()\n            return context\n\n    class DetailPrint(views.ChromePDFDetailView):\n        template_name = 'payment_detail.html'\n        queryset = Payments.objects.all()\n\n\n.. code-block:: python\n\n    from django_persian_pdf import views\n\n    class TemplatePrint(views.LatexPDFTemplateView):\n        template_name = 'payment_reports.tex'\n\n        def get_context_data(self, **kwargs):\n            context = super().get_context_data()\n            context['payments'] = Payments.objects.all()\n            return context\n\n    class DetailPrint(views.LatexPDFDetailView):\n        template_name = 'payment_detail.tex'\n        queryset = Payments.objects.all()\n\n3. Using latex template for persian requires you to have installed your persian fonts in home.\n\n.. code-block:: bash\n\n\n   mkdir -p ~/.fonts\n   cp /path_to_fonts/Vazirmatn.ttf ~/.fonts/\n   fc-cache -f -v\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Django class based views to generate pdf files using html or latex template.",
    "version": "0.0.5",
    "project_urls": {
        "Changelog": "https://github.com/bindruid/django-persian-pdf/blob/master/CHANGELOG.rst",
        "Repository": "https://github.com/bindruid/django-persian-pdf"
    },
    "split_keywords": [
        "pdf",
        " django",
        " persian",
        " xelatex"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "51c30e1ceebd722a110c606e01a705300aea6eafe5147b7a0bed173040029d8b",
                "md5": "bb562f7d6d7f7192d3984913c1bc2b10",
                "sha256": "403707f5d216a0456d9d29b958c538183967cacbbfa82ee29c997cb296e4827d"
            },
            "downloads": -1,
            "filename": "django_persian_pdf-0.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bb562f7d6d7f7192d3984913c1bc2b10",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 6225,
            "upload_time": "2024-04-18T07:54:25",
            "upload_time_iso_8601": "2024-04-18T07:54:25.106917Z",
            "url": "https://files.pythonhosted.org/packages/51/c3/0e1ceebd722a110c606e01a705300aea6eafe5147b7a0bed173040029d8b/django_persian_pdf-0.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4dd332db463fc3e31e4036a07370c4fef2490d994d8e5f162c0ecf34a540e982",
                "md5": "399f609ac4c2e728c63b2e7a2f8a8da2",
                "sha256": "d058a5c6496ed62de990be86494b5e3b0f83032e11c9f170da01710d9e8fa2cb"
            },
            "downloads": -1,
            "filename": "django_persian_pdf-0.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "399f609ac4c2e728c63b2e7a2f8a8da2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 6713,
            "upload_time": "2024-04-18T07:54:27",
            "upload_time_iso_8601": "2024-04-18T07:54:27.350117Z",
            "url": "https://files.pythonhosted.org/packages/4d/d3/32db463fc3e31e4036a07370c4fef2490d994d8e5f162c0ecf34a540e982/django_persian_pdf-0.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-18 07:54:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "bindruid",
    "github_project": "django-persian-pdf",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "django-persian-pdf"
}
        
Elapsed time: 0.24254s