evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a thumbnail generator that converts PDF pages to in-memory image buffers for further processing.
Your task is to implement a function that converts a specific page from a PDF document into an in-memory image buffer. The function should accept a PDF file path and a page number, then return the image data as a Node.js Buffer along with metadata about the image.
The converter should support multiple pages and return buffer data that can be used for in-memory processing such as streaming to clients or programmatic manipulation.
./sample.pdf, converting page 1 returns a Buffer containing image data, dimensions, and page number @test/**
* Converts a specific page from a PDF file to an in-memory image buffer.
*
* @param {string} pdfPath - Path to the PDF file
* @param {number} page - Page number to convert (1-indexed)
* @returns {Promise<{buffer: Buffer, size: string, page: number}>}
* Object containing the image buffer, dimensions as string (e.g., "768x512"), and page number
*/
async function convertPageToBuffer(pdfPath, page) {
// IMPLEMENTATION HERE
}
module.exports = { convertPageToBuffer };Provides PDF to image conversion with buffer output support.