evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
A utility that generates thumbnail images from PDF documents that are already loaded in memory as Buffer objects.
You are building a web API that receives PDF files as upload data. The PDFs need to be converted to thumbnail images without saving them to disk first. The API should support processing PDFs that are received as Buffer objects from file uploads or external API responses.
Create a module that converts PDF documents from memory (Buffer objects) into PNG thumbnail images. The module should:
The thumbnail should be 400 pixels wide with aspect ratio preserved, and saved with a density of 150 DPI for good web quality.
/**
* Generates a thumbnail image from a PDF Buffer.
*
* @param {Buffer} pdfBuffer - The PDF document as a Buffer
* @param {Object} options - Configuration options
* @param {string} options.outputDir - Directory where thumbnail will be saved
* @param {string} options.filename - Base filename for the output (without extension)
* @returns {Promise<Object>} Object containing { path, width, height, filename }
*/
async function generateThumbnail(pdfBuffer, options) {
// Implementation here
}
module.exports = { generateThumbnail };Provides PDF to image conversion capabilities with Buffer input support.