Trade Agreement Generator

Trade Agreement Generator

Create a professional trade agreement by filling out the details below.

Party Information

Party A (Seller/Provider)

Party B (Buyer/Recipient)

Scope of Agreement

Financial Terms

Agreement Term & Termination

Legal Clauses

Review & Download

Your generated trade agreement will appear here after you navigate from the 'Legal' tab.

Termination Conditions: ${formData.terminationConditions}

Renewal: ${formData.renewalTerms}

5. Confidentiality

${formData.confidentiality}

6. Governing Law and Dispute Resolution

This Agreement shall be governed by and construed in accordance with the laws of ${formData.governingLaw}.

Any dispute arising out of or in connection with this Agreement shall be resolved through ${formData.disputeResolution}.

7. Entire Agreement

This document constitutes the entire agreement between the Parties and supersedes all prior agreements and understandings, whether written or oral, relating to the subject matter of this Agreement.

PARTY A:

${formData.partyAName}



_________________________

By: ${formData.partyAContact}

PARTY B:

${formData.partyBName}



_________________________

By: ${formData.partyBContact}

`; const agreementOutput = document.getElementById('agreement-output'); const pdfContent = document.getElementById('pdf-content'); if (agreementOutput) agreementOutput.innerHTML = agreementHTML; if (pdfContent) pdfContent.innerHTML = agreementHTML; if(downloadPdfBtn) downloadPdfBtn.disabled = false; } async function handlePdfDownload() { const pdfContainer = document.getElementById('pdf-container'); if (!pdfContainer) { console.error('PDF content container not found'); return; } const { jsPDF } = window.jspdf; const button = document.getElementById('downloadPdfBtn'); if(button) { button.textContent = 'Generating...'; button.disabled = true; } // Temporarily make the container visible for rendering, it's already off-screen pdfContainer.classList.remove('invisible'); try { const canvas = await html2canvas(pdfContainer, { scale: 2, // Higher scale for better quality useCORS: true, logging: false, }); const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4', }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const canvasWidth = canvas.width; const canvasHeight = canvas.height; const ratio = canvasWidth / canvasHeight; let imgWidth = pdfWidth - 20; // with margin let imgHeight = imgWidth / ratio; let heightLeft = imgHeight; let position = 10; // top margin pdf.addImage(imgData, 'PNG', 10, position, imgWidth, imgHeight); heightLeft -= (pdfHeight - 20); while (heightLeft > 0) { position = -heightLeft - 10; // Adjust position for the new page pdf.addPage(); pdf.addImage(imgData, 'PNG', 10, position, imgWidth, imgHeight); heightLeft -= (pdfHeight - 20); } pdf.save(`Trade_Agreement_${getVal('partyAName','PartyA')}_${getVal('partyBName','PartyB')}.pdf`); } catch(error) { console.error("Error generating PDF:", error); } finally { if(button) { button.textContent = 'Download as PDF'; button.disabled = false; } // Hide the container again after capture pdfContainer.classList.add('invisible'); } } // --- EVENT LISTENERS --- tabButtons.forEach(button => { button.addEventListener('click', () => { const targetTab = parseInt(button.dataset.tab); changeTab(targetTab); }); }); if (nextBtn) { nextBtn.addEventListener('click', () => changeTab(currentTab + 1)); } if (prevBtn) { prevBtn.addEventListener('click', () => changeTab(currentTab - 1)); } if (regenerateButton) { regenerateButton.addEventListener('click', generateAgreement); } if (downloadPdfBtn) { downloadPdfBtn.addEventListener('click', handlePdfDownload); } // Initialize view updateTabDisplay(); });
Scroll to Top