Skip to content

About

PDF Thumbnail Generator is a Node.js package that allows you to fetch a PDF file from a URL, convert it to images, and generate thumbnails from those images.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

PDF Thumbnail Generator

PDF Thumbnail Generator is a Node.js package that allows you to fetch a PDF file from a URL, convert it to images, and generate thumbnails from those images.

Installation

You can install this package using npm:

npm install pdf-thumbnail-generator

How to use PDF Thumbnail Generator

Import the package at the beginning of your JavaScript file:

const pdfThumbnailGenerator = require('pdf-thumbnail-generator');

Fetch a PDF file from a URL and save it to a local path:

const pdfUrl = 'https://example.com/path-to-pdf.pdf';
const pdfFilePath = 'downloaded-pdf.pdf';

pdfThumbnailGenerator.fetchPDF(pdfUrl, pdfFilePath)
  .then(() => {
    // PDF fetched and saved
  })
  .catch((error) => {
    console.error(error);
  });

Convert the PDF to images and save them in an output directory:

const pdfPath = 'downloaded-pdf.pdf';
const outputDir = 'output-images';

pdfThumbnailGenerator.convertPDFToImages(pdfPath, outputDir)
  .then((result) => {
    // PDF converted to images
  })
  .catch((error) => {
    console.error(error);
  });

Generate a thumbnail from an image and save it to a specified path:

const imagePath = 'output-images/page-1.png';
const thumbnailPath = 'thumbnails/thumbnail.png';
const thumbnailSize = 200;

pdfThumbnailGenerator.generateThumbnail(imagePath, thumbnailPath, thumbnailSize)
  .then(() => {
    // Thumbnail generated and saved
  })
  .catch((error) => {
    console.error(error);
  });

About

PDF Thumbnail Generator is a Node.js package that allows you to fetch a PDF file from a URL, convert it to images, and generate thumbnails from those images.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages