Skip to content

intellisense/tc_pdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
)