evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a utility that validates PDF page numbers before attempting conversion operations. The tool should help prevent errors by checking page numbers against PDF constraints.
The utility should validate page numbers for PDF conversion operations and provide clear error handling.
The utility should integrate with a PDF conversion library to convert valid page numbers.
/**
* Validates a page number for PDF conversion.
*
* @param {number} pageNumber - The page number to validate (must be >= 1)
* @returns {number} The validated page number
* @throws {Error} If page number is less than 1
*/
function validatePageNumber(pageNumber) {
// IMPLEMENTATION HERE
}
/**
* Converts a specific page from a PDF to an image buffer.
*
* @param {string} pdfPath - Path to the PDF file
* @param {number} pageNumber - The page number to convert (1-indexed)
* @param {object} options - Conversion options (optional)
* @returns {Promise<Buffer>} Image buffer of the converted page
* @throws {Error} If page number is invalid
*/
async function convertPage(pdfPath, pageNumber, options = {}) {
// IMPLEMENTATION HERE
}
module.exports = {
validatePageNumber,
convertPage,
};Provides PDF to image conversion capabilities.