Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

`Turn.js <http://www.turnjs.com/>`_ integration to django projects
==================================================================

`django_turnit` provides a way to display PDF files in a `turn.js <http://www.turnjs.com/>`_ player.

Requirements
------------

With django_turnit, you can choose between several backends for PDF image extraction :

+ ghostscript :

This method does not seems to support threading...
The `Ghostscript <http://www.ghostscript.com/>`_ application / library. It can be installed as a package in linux
distributions, such an in debian / ubuntu :

.. code:: sh

$ sudo apt install ghostscript # on debian
$ sudo apt-get install ghostscript # on ubuntu


+ pdftocairo : Prefered method

- `pdftocairo <http://manpages.ubuntu.com/manpages/precise/man1/pdftocairo.1.html>`_ through subprocess

+ pdftoppm : Prefered method

- `pdftoppm <http://manpages.ubuntu.com/manpages/precise/man1/pdftoppm.1.html>`_ through subprocess

+ poppler : I've no clue on how to use it directly, which would be great, I was net able to setup the library at all...


Installation
------------

.. code:: sh

$ pip install django-turnit

This installs the packages that are required by django_turnit:

- `django <https://www.djangoproject.com/>`_ (< 1.10, I haven't yet tested django 1.10)
- `django-appconf <https://github.com/django-compressor/django-appconf>`_: Helper for configuration of applications
- `easy-thumbnails <https://github.com/SmileyChris/easy-thumbnails>`_: Creates thumbnails from images
- `pdfminer <https://github.com/euske/pdfminer>`_: Extract texts from PDF files

Those requirements may also be needed:

- `python-ghostscript <https://bitbucket.org/htgoebel/python-ghostscript>`_:
C python binding for the Ghostscript library, if you choose ghostscript as backend
-

.. code:: sh

$ python manage.py migrate django_turnit # Creates the table needed for caching the names of the page images

Usage
-----

`django_turnit` can create and manage page images for PDF files. This images are stored in the `media` folder, a database stores .

Management command
^^^^^^^^^^^^^^^^^^

The `turnit` command creates the missing thumbnails for each FileField containing a PDF file.

.. code:: sh

$ ./manage.py turnit <app_label>[.<model_name>[.<pk>[.<field_name>]]] [arg]

Where:

- <app_label> is the application label. If set, the whole application is scanned for PDF files, and they are thumbnailed.
- <model_name> is the madel name. If set, the model is scanned.
- <pk> is the row pk. If set, the row is scanned
- <field_name> field name.

Signals processing
^^^^^^^^^^^^^^^^^^

Settings
--------

`TURNIT_INPUT_SUPPORTED_FILE_TYPES`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Supported file MIME types.

.. code:: python

TURNIT_INPUT_SUPPORTED_FILE_TYPES = ['application/pdf', ]

`TURNIT_OUTPUT_MEDIA_ROOT`
^^^^^^^^^^^^^^^^^^^^^^^^^^

Name of the sub-folder created under the MEDIA_ROOT folder, to store the output image files.

.. code:: python

TURNIT_OUTPUT_MEDIA_ROOT = 'django_turnit'

`TURNIT_OUTPUT_FILE_FMT`
^^^^^^^^^^^^^^^^^^^^^^^^

Ghostscript output file name format.

.. code:: python

TURNIT_OUTPUT_FILE_FMT = '%(basename)s.%(i)03d.%(ext)s'


`TURNIT_OUTPUT_IMAGE_FORMAT`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Ghostscript output file format, as defined in `Ghostscript documentation <http://ghostscript.com/doc/current/Devices.htm#File_formats>`_.

You can choose between:

- PNG

- `png16m`: 24 bit color PNG (default value)
- `pnggray`: 8 bit gray scale PNG
- `png256`: 256 colors PNG
- `png16`: 16 colors PNG
- `pngmonod`: Black and white monochrome PNG

- JPEG

- `jpeg`: jpeg standard output

- TIFF

- `tiffgray`: 8-bit gray output.
- `tiff12nc`: 12-bit RGB output (4 bits per component).
- `tiff24nc`: 24-bit RGB output (8 bits per component).
- `tiff48nc`: 48-bit RGB output (16 bits per component).
- `tiff32nc`: 32-bit CMYK output (8 bits per component).
- `tiff64nc`: 64-bit CMYK output (16 bits per component).

.. code:: python

TURNIT_OUTPUT_IMAGE_FORMAT = 'png16m'

`TURNIT_GHOSTSCRIPT_GLOBAL_ARGS`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Global settings for ghostscript library.

.. note::

Global arguments order in important in ghostscript !
**You MUST start with the `-q` argument !**

.. code:: python

TURNIT_GHOSTSCRIPT_GLOBAL_ARGS = ['-q',
'-dNOPROMPT',
'-dNOPAUSE',
'-dBATCH',
'-dSAFER', ]

`TURNIT_GHOSTSCRIPT_EXTRA_ARGS`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Extra parameters for ghostscript. You can add format options here.

.. code:: python

TURNIT_GHOSTSCRIPT_EXTRA_ARGS = []

Metadata

Release files for django_turnit 0.2.1a2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distributions (sdists)

Source distribution for django_turnit 0.2.1a2
File Size Uploaded
django_turnit-0.2.1a2.zip 398.1 kB Details
django_turnit-0.2.1a2.tar.bz2 314.3 kB Details

Release files / django_turnit-0.2.1a2.zip

Download URL django_turnit-0.2.1a2.zip
Size 398.1 kB
Tags Source
SHA-256 checksum
How to use checksums
97496e3ef88396a150a71e72e28cf4c323b1a4bb1612d74cf0299e405743e705
BLAKE2b-256 checksum
How to use checksums
e4c1d2ed7e7319b6ef5287aa431f6f5fd6dc8557186b5aa7d09e323abbd08892
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / django_turnit-0.2.1a2.tar.bz2

Download URL django_turnit-0.2.1a2.tar.bz2
Size 314.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a9d186b90dcbea75b5ebc6a9f3a89b1c067da59ba99664495ca842f782675787
BLAKE2b-256 checksum
How to use checksums
79b277338f86334e3a06698bea3046fc3af7f768a794ecda6f6cb11e73db6c49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page