HEIF to DOC Converter

HEIF to DOC Converter

Convert your HEIF images to Microsoft Word DOC format with embedded images

Upload HEIF Files

Drop HEIF files here or click to browse
Supports .heif, .heic files up to 10MB each

Conversion Settings

90%
Processing files...
Your document is ready!
`;// Close MHTML structure (using direct base64 embedding instead of separate parts) // This approach embeds images directly in the HTML which works better for DOC files // Store the MHTML content this.document = mhtmlContent; } catch (error) { console.error('Document creation error:', error); throw new Error('Failed to create document: ' + error.message); } }// Helper function to convert blob to base64 blobToBase64(blob) { return new Promise((resolve, reject) => { const reader = new FileReader(); reader.onload = () => resolve(reader.result); reader.onerror = reject; reader.readAsDataURL(blob); }); }async downloadDocument() { try { const downloadButton = document.getElementById('downloadButton'); downloadButton.disabled = true; downloadButton.innerHTML = ' Preparing Download...';// Create DOC file using HTML format that Microsoft Word recognizes const blob = new Blob([this.document], { type: 'application/msword' }); const fileName = `converted-heif-images-${new Date().toISOString().split('T')[0]}.doc`; // Use appropriate save function if (typeof saveAs !== 'undefined') { saveAs(blob, fileName); } else { // Fallback to manual download const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = fileName; a.style.display = 'none'; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); } } catch (error) { console.error('Download error:', error); this.showError('Failed to download document: ' + error.message); } finally { const downloadButton = document.getElementById('downloadButton'); downloadButton.disabled = false; downloadButton.innerHTML = ' Download DOC File'; } }// Utility methods showProgress(text) { document.getElementById('progressSection').style.display = 'block'; document.getElementById('progressText').textContent = text; this.hideMessages(); }updateProgress(text, percentage) { document.getElementById('progressText').textContent = text; document.getElementById('progressFill').style.width = percentage + '%'; }hideProgress() { document.getElementById('progressSection').style.display = 'none'; }showSuccess(message) { const successSection = document.getElementById('successSection'); successSection.textContent = message; successSection.style.display = 'block'; this.hideError(); }showError(message) { const errorSection = document.getElementById('errorSection'); errorSection.textContent = message; errorSection.style.display = 'block'; this.hideSuccess(); }hideSuccess() { document.getElementById('successSection').style.display = 'none'; }hideError() { document.getElementById('errorSection').style.display = 'none'; }hideMessages() { this.hideSuccess(); this.hideError(); }showDownloadSection() { document.getElementById('downloadSection').style.display = 'block'; }hideDownloadSection() { document.getElementById('downloadSection').style.display = 'none'; }reset() { this.files = []; this.convertedImages = []; this.document = null; document.getElementById('fileInput').value = ''; this.updateFileList(); this.hideMessages(); this.hideProgress(); this.hideDownloadSection(); // Reset convert button const convertButton = document.getElementById('convertButton'); convertButton.disabled = false; convertButton.innerHTML = ' Convert to DOC'; } }