- Seamlessly integrates with pdf.js to efficiently parse PDFs and convert them into images.
- Supports multiple image formats:
jpg,png,webpfor versatile usage.
- Leverages jszip.js to bundle generated images into a ZIP file for one-click download.
- Automatically names files and ZIP archives for better organization of multipage content.
- Designed with asynchronous processing to ensure a smooth user experience.
- Comprehensive error handling with detailed error messages for easier debugging.
npm i @pardnchiu/pdf2image<scriptsrc="https://cdn.jsdelivr.net/npm/@pardnchiu/pdf2image@[VERSION]/dist/pdf2image.js"></script>import{pdf2image}from"https://cdn.jsdelivr.net/npm/@pardnchiu/pdf2image@[VERSION]/dist/pdf2image.esm.js";constconverter=newpdf2image({filename: "image-yyyy-MM-DD_hh:mm",// Specify output filename, supports date format templates [yyyy|MM|DD|hh|mm]file: [file],// Input PDF file from file input or other sourcesscale: 1.5,// Scale factor, default is 1.5type: "png"// Output image format [jpg|png|webp]});// Convert PDF to imagesconverter.convert().then(images=>{console.log("Successfully converted images:",images);});// Download compressed ZIP fileconverter.download().then(()=>{console.log("Images have been packed and downloaded!");});This source code project is licensed under the MIT License.
©️ 2024 邱敬幃 Pardn Chiu