PDF2JPG Pro – Convert PDF to Images
/* — CSS SEPARATION START — */
@import url(‘https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap’);:root {
–primary: #EA580C; /* Orange-600 */
–bg-dark: #0F172A;
}body {
font-family: ‘Inter’, sans-serif;
transition: background-color 0.3s, color 0.3s;
}/* Loading Spinner */
.loader {
border: 3px solid #f3f3f3;
border-radius: 50%;
border-top: 3px solid #EA580C;
width: 24px;
height: 24px;
animation: spin 1s linear infinite;
}@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}/* Dropzone Active */
.dropzone-active {
border-color: #EA580C !important;
background-color: rgba(234, 88, 12, 0.05) !important;
transform: scale(1.01);
}/* Image Card Hover */
.image-card {
transition: all 0.2s ease;
}
.image-card:hover {
transform: translateY(-2px);
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}/* Dark Mode */
.dark body {
background-color: var(–bg-dark);
color: #F9FAFB;
}
.dark .card {
background-color: #1E293B;
border-color: #334155;
}
/* — CSS SEPARATION END — */
tailwind.config = {
darkMode: ‘class’,
theme: {
extend: {
colors: {
// Converted to RGB to prevent potential parser conflicts with private fields (#)
primary: ‘rgb(234, 88, 12)’,
}
}
}
}
// Initialize PDF.js Worker
pdfjsLib.GlobalWorkerOptions.workerSrc = ‘https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.4.120/pdf.worker.min.js’;
Turn every page of your PDF document into a high-quality JPG image. Secure, fast, and free.
Drop PDF Document Here Extract all pages as images instantly
Select PDF
Converting… Initializing engine
document.pdf 0 Pages Converted
Download All (ZIP)
Convert Another
Privacy Note: Your PDF is processed locally in your browser. We do not upload your document to any server.
// — JAVASCRIPT SEPARATION START —// DOM Elements
const dropzone = document.getElementById(‘upload-stage’);
const processingStage = document.getElementById(‘processing-stage’);
const resultsStage = document.getElementById(‘results-stage’);
const fileInput = document.getElementById(‘fileInput’);
const progressBar = document.getElementById(‘progress-bar’);
const progressText = document.getElementById(‘progress-text’);
const imageGrid = document.getElementById(‘image-grid’);
const pageCountEl = document.getElementById(‘page-count’);
const fileNameDisplay = document.getElementById(‘file-name-display’);let isDarkMode = false;
let convertedImages = []; // Stores { blob, fileName, pageNum }
let currentPDFName = “document”;// — Event Listeners —
dropzone.addEventListener(‘click’, () => fileInput.click());
dropzone.addEventListener(‘dragover’, (e) => { e.preventDefault(); dropzone.classList.add(‘dropzone-active’); });
dropzone.addEventListener(‘dragleave’, () => dropzone.classList.remove(‘dropzone-active’));
dropzone.addEventListener(‘drop’, (e) => {
e.preventDefault();
dropzone.classList.remove(‘dropzone-active’);
if(e.dataTransfer.files.length) handleFile(e.dataTransfer.files[0]);
});fileInput.addEventListener(‘change’, (e) => {
if(e.target.files.length) handleFile(e.target.files[0]);
});// — Core Functions —async function handleFile(file) {
if (file.type !== ‘application/pdf’) {
alert(‘Please upload a valid PDF file.’);
return;
}currentPDFName = file.name.replace(‘.pdf’, ”);
fileNameDisplay.innerText = file.name;
// UI Switch
dropzone.classList.add(‘hidden’);
processingStage.classList.remove(‘hidden’);
convertedImages = [];
imageGrid.innerHTML = ”;try {
const arrayBuffer = await file.arrayBuffer();
const pdf = await pdfjsLib.getDocument(arrayBuffer).promise;
const totalPages = pdf.numPages;
pageCountEl.innerText = totalPages;// Iterate Pages
for (let i = 1; i canvas.toBlob(resolve, ‘image/jpeg’, 0.9));
const imgUrl = URL.createObjectURL(blob);
const imgName = `${currentPDFName}_page-${i}.jpg`;
convertedImages.push({ blob, name: imgName, url: imgUrl });// Add to Grid immediately
addImageToGrid(imgUrl, i, imgName);
}// Finish
processingStage.classList.add(‘hidden’);
resultsStage.classList.remove(‘hidden’);} catch (err) {
console.error(err);
alert(“Error reading PDF. It might be corrupted or password protected.”);
resetApp();
}
}function addImageToGrid(url, pageNum, name) {
const div = document.createElement(‘div’);
div.className = ‘image-card bg-white dark:bg-slate-800 p-3 rounded-xl shadow-sm border border-gray-200 dark:border-slate-700 flex flex-col’;
div.innerHTML = `
Page ${pageNum}
Download JPG
`;
imageGrid.appendChild(div);
}async function downloadZip() {
const btn = document.querySelector(‘button[onclick=”downloadZip()”]’);
const originalText = btn.innerHTML;
btn.innerHTML = ‘
Zipping…’;
btn.disabled = true;const zip = new JSZip();
convertedImages.forEach(img => {
zip.file(img.name, img.blob);
});const content = await zip.generateAsync({ type: “blob” });
const url = URL.createObjectURL(content);
const a = document.createElement(‘a’);
a.href = url;
a.download = `${currentPDFName}_images.zip`;
a.click();
btn.innerHTML = originalText;
btn.disabled = false;
}function resetApp() {
fileInput.value = ”;
convertedImages = [];
imageGrid.innerHTML = ”;
dropzone.classList.remove(‘hidden’);
processingStage.classList.add(‘hidden’);
resultsStage.classList.add(‘hidden’);
progressBar.style.width = ‘0%’;
}function toggleDarkMode() {
isDarkMode = !isDarkMode;
document.documentElement.classList.toggle(‘dark’);
const icon = document.getElementById(‘theme-icon’);
if(isDarkMode) {
icon.classList.remove(‘fa-moon’);
icon.classList.add(‘fa-sun’);
} else {
icon.classList.remove(‘fa-sun’);
icon.classList.add(‘fa-moon’);
}
}// — JAVASCRIPT SEPARATION END —
PDF To JPG: Overview and Usage Tips Use the PDF To JPG utility for tasks involving PDF documents. Review the tool interface for supported inputs and settings. For file-based tasks, keep a copy of your original file and check the output before using it.
Steps to get started Read the supported formats or input requirements shown in the tool. Choose the available options appropriate to your task. Run the tool and review its result for accuracy and quality. Related resources Try Compress PDF or PDF to Word for another document or digital task.
Related tools: JPG to PDF and Compress PDF . Review your output file after processing.