ONLINE TOOLKIT

Image to PDF

Fast, intuitive tools that work on any device.

Processed directly on your device, without uploading images to the server. Supports formats readable by your browser.

');win.document.close();status.textContent='Choose Save as PDF in the print dialog.';job?.success('Đã chuẩn bị ảnh để in PDF');return}const type=document.querySelector('#format').value,q=Number(document.querySelector('#quality').value);if(!(q>=0.1&&q<=1))throw Error('Quality must be between 0.1 and 1');const blob=await new Promise((ok,fail)=>c.toBlob(b=>b?ok(b):fail(Error('Could not export the image')),type,q));const ext=blob.type==='image/png'?'png':blob.type==='image/webp'?'webp':'jpg';const u=URL.createObjectURL(blob);const save=document.querySelector('#save-image');if(window.s2ndImageUrl)URL.revokeObjectURL(window.s2ndImageUrl);window.s2ndImageUrl=u;save.href=u;save.download='s2nd-image.'+ext;save.hidden=false;const pv=document.querySelector('#preview');pv.src=u;pv.hidden=false;job?.success('Đã xử lý ảnh thành công');status.textContent='Processed: '+w+' × '+h+' px, '+(blob.size/1024).toFixed(1)+' KB. Click Download below the result.'}catch(e){job?.error(e?.message||'Không thể xử lý ảnh');status.textContent=e.message}finally{btn.disabled=false;if(objectURL)URL.revokeObjectURL(objectURL)}};