Online Smart Office Forms & Template Generator

Online Smart Office Forms & Template Generator

Form Details

Preview

Your generated document will appear here.

Customize Form Templates

Edit the HTML for each template. Use placeholders like `{{variableName}}`.

{{clientAddress}}

Invoice #: {{invoiceNumber}}

Date: {{invoiceDate}}

Description Amount
{{itemDescription}} $ {{itemAmount}}
Total: $ {{itemAmount}}
`, memo: `

MEMORANDUM

TO: {{memoTo}} FROM: {{memoFrom}} DATE: {{memoDate}} SUBJECT: {{memoSubject}}

{{memoBody}}

`, agenda: `

{{meetingTitle}}

Date: {{meetingDate}} | Time: {{meetingTime}}

Agenda Items

{{agendaItems}}
` }; let lastGeneratedHTML = ''; // DOM Elements const formTypeSelect = document.getElementById('formType'); const dynamicInputs = document.getElementById('dynamic-inputs'); const generateBtn = document.getElementById('generateBtn'); const formPreview = document.getElementById('form-preview'); const pdfDownloadContainer = document.getElementById('pdfDownloadContainer'); const saveTemplatesBtn = document.getElementById('saveTemplatesBtn'); // Input definitions for each form type const formInputs = { invoice: [ { id: 'yourCompany', label: 'Your Company', placeholder: 'Acme Inc.' }, { id: 'yourAddress', label: 'Your Address', placeholder: '123 Main St, Anytown, USA' }, { id: 'clientName', label: 'Client Name', placeholder: 'John Doe' }, { id: 'clientAddress', label: 'Client Address', placeholder: '456 Oak Ave, Someplace, USA' }, { id: 'invoiceNumber', label: 'Invoice #', placeholder: '12345' }, { id: 'invoiceDate', label: 'Date', type: 'date' }, { id: 'itemDescription', label: 'Item Description', placeholder: 'Web Development Services' }, { id: 'itemAmount', label: 'Amount ($)', type: 'number', placeholder: '1500.00' } ], memo: [ { id: 'memoTo', label: 'To', placeholder: 'All Staff' }, { id: 'memoFrom', label: 'From', placeholder: 'Management' }, { id: 'memoDate', label: 'Date', type: 'date' }, { id: 'memoSubject', label: 'Subject', placeholder: 'Q3 Policy Updates' }, { id: 'memoBody', label: 'Body', type: 'textarea', rows: 5, placeholder: 'This memo is to inform you of...' } ], agenda: [ { id: 'meetingTitle', label: 'Meeting Title', placeholder: 'Weekly Sync' }, { id: 'meetingDate', label: 'Date', type: 'date' }, { id: 'meetingTime', label: 'Time', placeholder: '10:00 AM' }, { id: 'agendaItems', label: 'Agenda Items', type: 'textarea', rows: 6, placeholder: '1. Review of last week\'s action items\n2. Project A status update\n3. Open floor for questions' } ] }; function updateDynamicInputs() { const type = formTypeSelect.value; dynamicInputs.innerHTML = ''; formInputs[type].forEach(input => { let inputHtml = ''; if (input.type === 'textarea') { inputHtml = ``; } else { inputHtml = ``; } dynamicInputs.innerHTML += `
${inputHtml}
`; }); // Set date fields to today formInputs[type].filter(i => i.type === 'date').forEach(i => { if(document.getElementById(i.id)) document.getElementById(i.id).valueAsDate = new Date(); }); } generateBtn.addEventListener('click', () => { const type = formTypeSelect.value; let generatedHtml = templates[type]; formInputs[type].forEach(input => { const value = document.getElementById(input.id).value; generatedHtml = generatedHtml.replace(new RegExp(`{{${input.id}}}`, 'g'), value); }); formPreview.innerHTML = generatedHtml; lastGeneratedHTML = generatedHtml; pdfDownloadContainer.style.display = 'flex'; }); formTypeSelect.addEventListener('change', updateDynamicInputs); // Template Library Logic function loadTemplates() { document.getElementById('invoiceTemplate').value = templates.invoice.trim(); document.getElementById('memoTemplate').value = templates.memo.trim(); document.getElementById('agendaTemplate').value = templates.agenda.trim(); } saveTemplatesBtn.addEventListener('click', () => { templates.invoice = document.getElementById('invoiceTemplate').value; templates.memo = document.getElementById('memoTemplate').value; templates.agenda = document.getElementById('agendaTemplate').value; alert('Templates saved successfully!'); }); // PDF Generation document.getElementById('pdf-download-button').addEventListener('click', () => { if (!lastGeneratedHTML) { alert("Please generate a document first."); return; } const reportContainer = document.createElement('div'); reportContainer.innerHTML = `
${lastGeneratedHTML}
`; document.body.appendChild(reportContainer); const reportElement = document.getElementById('pdf-report-template'); const { jsPDF } = window.jspdf; html2canvas(reportElement, { scale: 2 }).then(canvas => { const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'portrait', unit: 'px', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const ratio = canvas.width / canvas.height; let finalImgWidth = pdfWidth - 40; let finalImgHeight = finalImgWidth / ratio; if (finalImgHeight > pdfHeight - 40) { finalImgHeight = pdfHeight - 40; finalImgWidth = finalImgHeight * ratio; } const x = (pdfWidth - finalImgWidth) / 2; const y = 20; pdf.addImage(imgData, 'PNG', x, y, finalImgWidth, finalImgHeight); pdf.save('generated-document.pdf'); document.body.removeChild(reportContainer); }); }); // Tab functionality window.changeTab = function(event, tabName) { document.querySelectorAll('.tab').forEach(tab => tab.classList.remove('active')); event.currentTarget.classList.add('active'); document.querySelectorAll('.tab-content').forEach(content => content.classList.remove('active')); document.getElementById(tabName).classList.add('active'); } // Initial Load updateDynamicInputs(); loadTemplates(); });
Scroll to Top