or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-7/

PDF Thumbnail Generator

A service that generates base64-encoded thumbnail images from PDF documents for embedding in web APIs and HTML.

Capabilities

Convert PDF to Base64 thumbnail

  • Given a PDF file path, convert the first page to a base64-encoded PNG image @test
  • The base64 output can be embedded directly in an HTML img tag @test

Handle multiple pages

  • Given a PDF with multiple pages, convert pages 1 and 3 to base64-encoded images @test

Configure thumbnail dimensions

  • Convert a PDF page to base64 with custom width of 300 pixels while maintaining aspect ratio @test

Implementation

@generates

API

/**
 * Converts a PDF page to a base64-encoded image string
 *
 * @param {string} pdfPath - Path to the PDF file
 * @param {number} pageNumber - Page number to convert (1-indexed)
 * @param {object} options - Configuration options
 * @param {number} options.width - Desired image width in pixels
 * @param {boolean} options.preserveAspectRatio - Whether to maintain aspect ratio
 * @returns {Promise<string>} Base64-encoded image string
 */
async function convertToBase64(pdfPath, pageNumber, options);

/**
 * Converts multiple PDF pages to base64-encoded images
 *
 * @param {string} pdfPath - Path to the PDF file
 * @param {number[]} pages - Array of page numbers to convert
 * @param {object} options - Configuration options
 * @returns {Promise<Array<{page: number, base64: string}>>} Array of base64 results
 */
async function convertMultipleToBase64(pdfPath, pages, options);

module.exports = {
  convertToBase64,
  convertMultipleToBase64
};

Dependencies { .dependencies }

pdf2pic { .dependency }

Provides PDF to image conversion with base64 output support.

@satisfied-by