evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
A utility that converts multiple PDF pages to images asynchronously using promise-based operations.
Build a module that converts specified pages from a PDF document to image format. The module should handle multiple pages concurrently and provide error handling for invalid inputs.
Your module should accept a PDF file path and an array of page numbers, then convert all requested pages asynchronously. The function must handle multiple pages concurrently and return results for all pages (including both successes and failures).
pdfPath (string): Path to the PDF filepages (array of numbers): Page numbers to convert, 1-indexed (first page is 1)options (object, optional): Configuration for the conversion
format (string): Output image format, defaults to 'png'savePath (string): Directory to save images, defaults to './output'Returns a Promise that resolves to an array of result objects, one for each requested page. Each result contains:
page (number): The page number that was attemptedsuccess (boolean): Whether the conversion succeededpath (string): Path to the saved image file (only if successful)error (string): Error message describing what went wrong (only if failed)/**
* Converts specified pages from a PDF to images asynchronously.
*
* @param {string} pdfPath - Path to the PDF file
* @param {number[]} pages - Array of page numbers to convert (1-indexed)
* @param {Object} options - Configuration options
* @param {string} options.format - Output format (default: 'png')
* @param {string} options.savePath - Save directory (default: './output')
* @returns {Promise<Array<{page: number, success: boolean, path?: string, error?: string}>>}
*/
async function convertPages(pdfPath, pages, options = {}) {
// Implementation here
}
module.exports = { convertPages };Provides PDF to image conversion capabilities.