Skip to content

Latest commit

 

History

History
63 lines (39 loc) · 1.53 KB

README.rst

File metadata and controls

63 lines (39 loc) · 1.53 KB

Thumbor / PDF Preview

This extension provides preview for PDF.

Features

Given a PDF URL return preview image of first page

Installation

  • Prerequisite: Following system libraries are required:

  • Install using pip

    $ pip install tc_pdf
  • Register the extension within Thumbor's configuration file

    COMMUNITY_EXTENSIONS = [
        'tc_pdf',
        ...
    ]
  • Launch thumbor with the Thumbor Community custom application:

    $ thumbor -a tc_core.app.App

Usage

tc_pdf handler route requires /pdf/ in URL after all filters but before the resource URL part e.g.

http://<thumbor_server>/unsafe/240x240/smart/pdf/localhost:8000/media/document/test.pdf

If you are using libthumbor to generate URLs then you can use this patch for CryptoURL class and then use it like this:

from crypto import CryptoURL

crypto = CryptoURL(key='my-security-key')

encrypted_url = crypto.generate(
    width=300,
    height=200,
    smart=True,
    image_url='/path/to/my/pdf_file.pdf',
    pdf=True, # <-- Pass this
)