All Projects → scandel → Pdfthumbnails

scandel / Pdfthumbnails

A small script to generate thumbnail images for pdf files, based on pdf.js

Projects that are alternatives of or similar to Pdfthumbnails

Caj2pdf
Convert CAJ (China Academic Journals) files to PDF. 转换中国知网 CAJ 格式文献为 PDF。佛系转换,成功与否,皆是玄学。
Stars: ✭ 1,063 (+1510.61%)
Mutual labels:  pdf
Vivliostyle Cli
⚒ Supercharge command-line publication workflow.
Stars: ✭ 57 (-13.64%)
Mutual labels:  pdf
Resume Builder
Resume Builder is a free open-source project that allows anyone to easily maintain and build any kind of resume.
Stars: ✭ 62 (-6.06%)
Mutual labels:  pdf
O
🌀 Text editor suitable for writing git commit messages and editing Markdown files. Can build executables and jump to errors at the press of `ctrl-space`, for several programming languages. Can format code with `ctrl-w`. Provides general syntax highlighting, rainbow parenthesis and cut/paste portals. o is intentionally limited to VT100.
Stars: ✭ 54 (-18.18%)
Mutual labels:  pdf
Gulp Markdown Pdf
Markdown to PDF
Stars: ✭ 56 (-15.15%)
Mutual labels:  pdf
Python Documentcloud
A deprecated Python wrapper for the DocumentCloud API
Stars: ✭ 60 (-9.09%)
Mutual labels:  pdf
Stories About Ming Dynasty
明朝那些事儿(全七卷)
Stars: ✭ 52 (-21.21%)
Mutual labels:  pdf
Gopdf
pdf document generation library
Stars: ✭ 63 (-4.55%)
Mutual labels:  pdf
Documentreader
This library reads word documents (.doc and .docx), txt and PDF files, and gives the output content of the document as a String.
Stars: ✭ 57 (-13.64%)
Mutual labels:  pdf
Html to pdf
Generate a simple invoice PDF from HTML using puppeteer & handlebars
Stars: ✭ 62 (-6.06%)
Mutual labels:  pdf
Diff Pdf
A simple tool for visually comparing two PDF files
Stars: ✭ 1,080 (+1536.36%)
Mutual labels:  pdf
Node Pdf Invoice
A Phantom free PDF invoice generator built with PDFKit
Stars: ✭ 56 (-15.15%)
Mutual labels:  pdf
Academic Pandoc Template
Write beautiful academic texts with the distraction-free Pandoc Markdown and typademic.
Stars: ✭ 60 (-9.09%)
Mutual labels:  pdf
Ramayana book
Ramayana Book ( One of the two great epics of Hinduism ) ascribed by Valmiki
Stars: ✭ 52 (-21.21%)
Mutual labels:  pdf
Blabel
🏷 Python label/sticker PDF generation. HTML templates, built-in barcodes, qr codes, and other goodies
Stars: ✭ 63 (-4.55%)
Mutual labels:  pdf
Docker Texlive
A docker container containing an installation of texlive as well as several useful scripts.
Stars: ✭ 52 (-21.21%)
Mutual labels:  pdf
Openhtmltopdf
An HTML to PDF library for the JVM. Based on Flying Saucer and Apache PDF-BOX 2. With SVG image support. Now also with accessible PDF support (WCAG, Section 508, PDF/UA)!
Stars: ✭ 1,096 (+1560.61%)
Mutual labels:  pdf
Notion Pdf Export
A tool to allow batch PDF export for free Notion users. You can export as HTML and then use this tool to convert those into PDFs.
Stars: ✭ 66 (+0%)
Mutual labels:  pdf
Knowledge Base
pdf,txt,djvu, various useful books
Stars: ✭ 63 (-4.55%)
Mutual labels:  pdf
Superfileview
基于腾讯浏览服务Tbs,使用X5Webkit内核,实现文件的展示功能,支持多种文件格式
Stars: ✭ 1,115 (+1589.39%)
Mutual labels:  pdf

PDF Thumbnails

A small script to parse html files and generate a source image for img elements with a data-pdf-thumbnail-file attribute linking to a pdf file.
The image is a view of the first page of the pdf. The script relies on the pdf.js library.

Online demo

See a PDF Thumbnails demo here.

Getting started

First get a local copy of the code, clone it using git:

$ git clone git://github.com/scandel/pdfThumbnails
$ cd pdfThumbnails

Then get a local copy of pdf.js (>=2.0). Use the prebuilt version that you can find on this page. Download and extract it. You only need to keep the build directory (with both pdf.js and pdf.worker.js). Make sure your directory structure looks like:

    pdfThumbnails
    |--pdf.js
    |  |--build
    |     |--pdf.js
    |     |--pdf.worker.js
    |--pdfThumbnails.js
    |--index.html
    |--example.pdf
    |--pdf.png
    ...

Now visit index.html in your browser, you should see the demo page with thumbnails of example.pdf.

Use it in your own project

You just need to keep the pdfThumbnails.js file from this project, and the pdf.js and pdf.worker.js files from pdf.js (let them both in the same directory as pdf.js will try to load the worker). In your html file, include the javascripts:

<script src="/path/to/pdfThumbnails.js" data-pdfjs-src="/path/to/pdf.js/build/pdf.js"></script>

The data-pdfjs-src attribute specifies the path of the library, which will only be loaded if there's any PDF thumbnail to display in the page.

To show a thumbnail, write an img element with a data-pdf-thumbnail-file attribute:

<img data-pdf-thumbnail-file="/my/file.pdf">

The pdf file path is a relative or absolute path to a file hosted on your site (no cross domain request).

You can add a width or a height in pixels for the generated image. If not, the size of the generated image will be the one of the pdf.

<img data-pdf-thumbnail-file="/my/file.pdf" data-pdf-thumbnail-width="200">
<img data-pdf-thumbnail-file="/my/file.pdf" data-pdf-thumbnail-height="150">

You can also add a src attribute to the image, which will act as a placeholder:

<img data-pdf-thumbnail-file="/my/file.pdf" src="pdf.png">

This way:

  • the image in src will be shown to the user during the loading and rendering time of the pdf, and the space of the image will be filled when the page is shown to the user;
  • if an error occurs (file not found or impossible to open), the user will still see something.

Errors (file not found or wrong format) are logged in the console.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].