Document Fraudulent Charges or Transactions Dispute Letter
Edit Your Letter
`;// Convert the template to a Blob
const blob = new Blob(['\ufeff', template], {
type: 'application/msword',
});// Save the Blob as a Word document
saveAs(blob, 'Credit_Report_Dispute_Letter.doc');
}function downloadPDF() {
console.log('Download PDF button clicked.');const { jsPDF } = window.jspdf;
const pdf = new jsPDF('p', 'mm', 'a4'); // A4 portrait mode
const content = document.getElementById('letterEditor');// Temporarily adjust styles to ensure all content is visible
const originalStyles = {
overflow: content.style.overflow,
height: content.style.height,
position: content.style.position,
};
content.style.overflow = 'visible';
content.style.height = 'auto';
content.style.position = 'static';// Use html2canvas to render the content
html2canvas(content, {
scale: 2, // Increase scale for better quality
useCORS: true, // Fix issues with external resources
logging: true, // Enable logging for debugging
allowTaint: true, // Allow tainted canvas (if needed)
width: 1100, // Set fixed width for rendering
windowWidth: 1100, // Set fixed width for rendering
}).then(canvas => {
console.log('Canvas rendered successfully.');// Restore original styles
content.style.overflow = originalStyles.overflow;
content.style.height = originalStyles.height;
content.style.position = originalStyles.position;const imgData = canvas.toDataURL('image/png');
const pdfWidth = 210; // A4 width in mm
const pdfHeight = 297; // A4 height in mm
const margin = 10; // Margin in mm
const imgWidth = pdfWidth - 2 * margin; // Image width after margins
const imgHeight = (canvas.height * imgWidth) / canvas.width; // Maintain aspect ratiolet position = 0; // Track the position of the content
let pageHeightLeft = pdfHeight - 2 * margin; // Height left on the current page// Add the first page
pdf.addImage(imgData, 'PNG', margin, margin, imgWidth, imgHeight, undefined, 'FAST');
position += pageHeightLeft;// Add additional pages if the content is too long
while (position < imgHeight) {
pdf.addPage(); // Add a new page
pdf.addImage(imgData, 'PNG', margin, margin - position, imgWidth, imgHeight, undefined, 'FAST');
position += pageHeightLeft;
}// Save the PDF
pdf.save('Credit_Report_Dispute_Letter.pdf');
console.log('PDF saved successfully.');
}).catch(error => {
console.error("Error rendering canvas:", error);// Restore original styles in case of an error
content.style.overflow = originalStyles.overflow;
content.style.height = originalStyles.height;
content.style.position = originalStyles.position;
});
}