Convert PDF to JPG Online Free

Turn your PDF pages into high-quality JPG images.

Drop to Upload

The Best Free Tool to Convert PDF to JPG

Turn your PDF pages into high-quality images instantly. SanPDF Pro offers a secure, fast, and free online converter that works directly in your browser without uploading your sensitive data.

No Uploads Needed 100% Free Secure & Private

How to Convert PDF to Image Online

1

Upload PDF

Select a PDF file from your computer, or simply drag and drop it into the upload box to get started.

2

Select Pages

Choose which pages to convert. You can also adjust the output format (JPG/PNG) and image quality.

3

Download Images

Click "Convert". Your pages will be converted to images instantly. Download them individually or as a ZIP file.

Why Use SanPDF Pro?

Secure & Private

We use client-side processing (WebAssembly). Your files stay on your device and are never uploaded to our servers, ensuring 100% privacy.

High Quality Output

Choose from Normal, High, or Ultra quality settings to get the perfect balance between image clarity and file size.

Multiple Formats

Convert your PDF pages to standard JPG format for photos or PNG for graphics requiring higher fidelity.

Free & Unlimited

Convert as many files as you want without any cost. No watermarks, no sign-up required.

The Ultimate Guide to Converting PDF to JPG

In today's digital world, the need to convert file formats is a common task. Whether you're a student, a professional designer, or an office worker, you've likely faced a situation where you needed to extract an image from a PDF or share a PDF page as an image. Our PDF to JPG converter is the perfect solution, providing a seamless, fast, and high-quality conversion experience right in your browser.

Why Convert PDF to Image?

  • Social Media Sharing: Platforms like Instagram and Facebook are optimized for images. Converting a PDF page to a JPG makes it easy to share content visually.
  • Website Integration: Embedding a JPG image is often easier and faster than embedding a PDF viewer on a webpage.
  • Presentations: Quickly insert a specific chart or graph from a PDF report into your PowerPoint or Google Slides presentation.
  • Easy Viewing: Images can be opened on any device without needing a specific PDF reader app.

Tips for Best Results

To get the best quality images from your PDF:

  • Choose the Right Format: Use JPG for photos and complex images to save space. Use PNG for text-heavy documents or graphics with sharp lines to preserve clarity.
  • Select High Quality: If you plan to print the images or view them on large screens, select the "High" or "Ultra" quality option in the toolbar.
  • Check Page Range: If you only need specific pages, use the range selector (e.g., "1-5") to save time and download only what you need.

Frequently Asked Questions

Is it safe to convert sensitive documents?
Yes. SanPDF Pro uses client-side processing. Your files are converted directly in your browser and are never uploaded to our servers, ensuring your data remains private.
Can I convert multiple pages at once?
Yes! You can convert all pages in a PDF document at once. If you select multiple pages, they will be packaged into a convenient ZIP file for download.
Does this work on mobile phones?
Yes! SanPDF Pro is fully responsive. You can convert PDFs to images directly from your iPhone, iPad, or Android device using your mobile browser.
Is there a file size limit?
Since the conversion happens locally in your browser, the limit depends on your device's memory. However, our tool is optimized to handle large PDF files efficiently without crashing.
Can I convert password-protected PDFs?
For security reasons, we cannot process encrypted files directly. You will need to remove the password from your PDF before uploading it for conversion.
Do I need to install any software?
No installation is required. SanPDF Pro works entirely in your web browser, compatible with Windows, Mac, Linux, iOS, and Android.
``` ### 2. Create `assets/js/pdf-to-jpg.js` ```diff /** * PDF to JPG Tool Logic */ const PDFToJPGTool = (() => { // State let state = { file: null, pdfDoc: null, selectedPages: new Set(), config: { color: 'brand' } }; // DOM Elements let els = {}; // Initialize const init = (config) => { state.config = { ...state.config, ...config }; els = { uploadContainer: document.getElementById('upload-component'), dropZone: document.getElementById('drop-zone'), dropZoneOverlay: document.getElementById('drop-zone-overlay'), fileInput: document.getElementById('fileInput'), toolInterface: document.getElementById('tool-interface'), pagesGrid: document.getElementById('pages-grid'), resultSection: document.getElementById('result-section'), toolToolbar: document.getElementById('tool-toolbar'), outputFilename: document.getElementById('output-filename'), btnConvert: document.getElementById('btn-convert'), btnConvertText: document.getElementById('btn-convert-text'), btnConvertLoader: document.getElementById('btn-convert-loader'), btnClear: document.getElementById('btn-clear'), btnSelectAll: document.getElementById('btn-select-all'), btnDeselectAll: document.getElementById('btn-deselect-all'), btnApplyRange: document.getElementById('btn-apply-range'), pageRangeInput: document.getElementById('page-range-input'), }; // Override Upload Component Behavior const uploadBox = els.uploadContainer ? els.uploadContainer.querySelector('label#uploadBox') : null; if (uploadBox) { const newUploadBox = uploadBox.cloneNode(true); uploadBox.parentNode.replaceChild(newUploadBox, uploadBox); const inputInside = newUploadBox.querySelector('input[type="file"]'); if (inputInside) { els.fileInput = inputInside; } } if (els.fileInput) { els.fileInput.removeAttribute('multiple'); els.fileInput.addEventListener('change', handleFileSelect); els.dropZone.addEventListener('drop', (e) => { e.preventDefault(); e.stopPropagation(); if (els.dropZoneOverlay) els.dropZoneOverlay.classList.remove('opacity-100'); if (e.dataTransfer.files && e.dataTransfer.files.length > 0) { handleFile(e.dataTransfer.files[0]); } }); els.dropZone.addEventListener('dragenter', (e) => { e.preventDefault(); if (els.dropZoneOverlay) els.dropZoneOverlay.classList.add('opacity-100'); }); els.dropZone.addEventListener('dragover', (e) => e.preventDefault()); els.dropZone.addEventListener('dragleave', (e) => { if (!e.currentTarget.contains(e.relatedTarget)) { if (els.dropZoneOverlay) els.dropZoneOverlay.classList.remove('opacity-100'); } }); } // Event Listeners els.btnConvert.addEventListener('click', handleConvert); if (els.btnClear) els.btnClear.addEventListener('click', () => location.reload()); if (els.btnSelectAll) els.btnSelectAll.addEventListener('click', selectAll); if (els.btnDeselectAll) els.btnDeselectAll.addEventListener('click', deselectAll); if (els.btnApplyRange) els.btnApplyRange.addEventListener('click', applyPageRange); if (els.pageRangeInput) { els.pageRangeInput.addEventListener('keydown', (e) => { if (e.key === 'Enter') { e.preventDefault(); applyPageRange(); } }); } }; const handleFileSelect = (e) => { if (e.target.files && e.target.files.length > 0) { handleFile(e.target.files[0]); } e.target.value = ''; }; const handleFile = async (file) => { const isPdf = file.type === 'application/pdf' || file.name.toLowerCase().endsWith('.pdf'); if (!isPdf) { alert('Please select a PDF file.'); return; } state.file = file; try { if (typeof window.ThumbnailGenerator === 'undefined') throw new Error("ThumbnailGenerator not loaded"); state.pdfDoc = await window.ThumbnailGenerator.loadPdfDocument(file); renderPages(); } catch (error) { console.error(error); alert("Error loading PDF: " + (error.message || "Unknown error")); } }; const renderPages = async () => { els.pagesGrid.innerHTML = ''; state.selectedPages.clear(); updateUI(); // Show Interface els.uploadContainer.classList.add('hidden'); els.toolInterface.classList.remove('hidden'); els.toolInterface.classList.add('flex'); els.pagesGrid.classList.remove('hidden'); for (let i = 1; i <= state.pdfDoc.numPages; i++) { // Default select all state.selectedPages.add(i); const item = document.createElement('div'); item.className = "group relative bg-slate-50 dark:bg-slate-800/50 p-2 rounded-xl shadow-sm border border-slate-200 dark:border-slate-700 cursor-pointer transition-all hover:shadow-md ring-2 ring-brand-500"; item.dataset.page = i; item.onclick = () => togglePage(i, item); item.innerHTML = `
Page ${i}
`; els.pagesGrid.appendChild(item); window.ThumbnailGenerator.renderPageThumbnail(state.pdfDoc, i).then(url => { const imgContainer = item.querySelector('.relative'); const spinner = item.querySelector('.loading-spinner'); if (spinner) spinner.remove(); const img = document.createElement('img'); img.src = url; img.className = "object-contain w-full h-full"; imgContainer.insertBefore(img, imgContainer.firstChild); }); } updateUI(); }; const togglePage = (pageNum, el) => { if (state.selectedPages.has(pageNum)) { state.selectedPages.delete(pageNum); el.classList.remove('ring-2', 'ring-brand-500'); el.querySelector('.selection-overlay').classList.remove('flex'); el.querySelector('.selection-overlay').classList.add('hidden'); } else { state.selectedPages.add(pageNum); el.classList.add('ring-2', 'ring-brand-500'); el.querySelector('.selection-overlay').classList.remove('hidden'); el.querySelector('.selection-overlay').classList.add('flex'); } updateUI(); }; const selectAll = () => { const items = els.pagesGrid.children; for (let item of items) { const page = parseInt(item.dataset.page); if (!state.selectedPages.has(page)) togglePage(page, item); } }; const deselectAll = () => { const items = els.pagesGrid.children; for (let item of items) { const page = parseInt(item.dataset.page); if (state.selectedPages.has(page)) togglePage(page, item); } }; const applyPageRange = () => { const rangeStr = els.pageRangeInput.value; const pagesToSelect = new Set(); const parts = rangeStr.split(','); parts.forEach(part => { const trimmed = part.trim(); if (trimmed.includes('-')) { const [start, end] = trimmed.split('-').map(Number); if (!isNaN(start) && !isNaN(end)) { for (let i = start; i <= end; i++) { if (i >= 1 && i <= state.pdfDoc.numPages) pagesToSelect.add(i); } } } else { const page = Number(trimmed); if (!isNaN(page) && page >= 1 && page <= state.pdfDoc.numPages) { pagesToSelect.add(page); } } }); state.selectedPages.clear(); const items = els.pagesGrid.children; for (let item of items) { const page = parseInt(item.dataset.page); // Reset item.classList.remove('ring-2', 'ring-brand-500'); item.querySelector('.selection-overlay').classList.remove('flex'); item.querySelector('.selection-overlay').classList.add('hidden'); if (pagesToSelect.has(page)) { state.selectedPages.add(page); item.classList.add('ring-2', 'ring-brand-500'); item.querySelector('.selection-overlay').classList.remove('hidden'); item.querySelector('.selection-overlay').classList.add('flex'); } } updateUI(); }; const updateUI = () => { els.btnConvert.disabled = state.selectedPages.size === 0; }; const handleConvert = async () => { if (state.selectedPages.size === 0) return; els.btnConvert.disabled = true; els.btnConvertText.textContent = 'Converting...'; els.btnConvertLoader.classList.remove('hidden'); try { if (typeof JSZip === 'undefined') throw new Error("JSZip library not loaded"); const zip = new JSZip(); const pages = Array.from(state.selectedPages).sort((a, b) => a - b); const baseName = els.outputFilename.value.trim() || 'images'; // If only one page, we might want to download just the image, but zip is standard for this tool usually. // Let's support single file download if only 1 page is selected. const isSingle = pages.length === 1; for (let i = 0; i < pages.length; i++) { const pageNum = pages[i]; els.btnConvertText.textContent = `Processing Page ${pageNum}...`; // Render at high quality (2000px width approx) const dataUrl = await window.ThumbnailGenerator.renderPageThumbnail(state.pdfDoc, pageNum, 2000); const data = dataUrl.split(',')[1]; if (isSingle) { // Single file download logic const link = document.createElement('a'); link.href = dataUrl; link.download = `${baseName}.jpg`; link.click(); // Mock result for UI showResult(null, `${baseName}.jpg`, dataUrl); return; } else { const pageStr = String(pageNum).padStart(3, '0'); zip.file(`${baseName}_page_${pageStr}.jpg`, data, {base64: true}); } } els.btnConvertText.textContent = 'Zipping...'; const content = await zip.generateAsync({ type: "blob" }); const filename = baseName.toLowerCase().endsWith('.zip') ? baseName : baseName + '.zip'; const url = URL.createObjectURL(content); showResult(content, filename, url); } catch (error) { console.error(error); alert("An error occurred: " + error.message); } finally { els.btnConvert.disabled = false; els.btnConvertText.textContent = 'Convert to JPG'; els.btnConvertLoader.classList.add('hidden'); } }; const showResult = (blob, filename, url) => { // Reuse the result section logic from split.js if (els.toolToolbar) els.toolToolbar.classList.add('hidden'); els.pagesGrid.classList.add('hidden'); els.resultSection.classList.remove('hidden'); els.resultSection.classList.add('flex'); const fileSize = blob ? (blob.size / 1024 / 1024).toFixed(2) + ' MB' : 'Image File'; els.resultSection.innerHTML = `

Ready!

${filename} (${fileSize})

Download
`; els.resultSection.scrollIntoView({ behavior: 'smooth', block: 'center' }); }; return { init }; })(); ```