diff --git a/resources/views/templates/corporate/bank-accounts.blade.php b/resources/views/templates/corporate/bank-accounts.blade.php index 796338a..d3695b3 100644 --- a/resources/views/templates/corporate/bank-accounts.blade.php +++ b/resources/views/templates/corporate/bank-accounts.blade.php @@ -492,6 +492,8 @@ padding: 0 !important; width: 210mm !important; height: 297mm !important; + max-height: 297mm !important; + overflow: hidden !important; } #letterheadPrintArea, #letterheadPrintArea * { visibility: visible !important; @@ -507,6 +509,7 @@ border-radius: 0 !important; margin: 0 !important; background: #ffffff !important; + box-sizing: border-box !important; } @page { size: A4 portrait; @@ -680,7 +683,7 @@ {!! t('Yazdır / Print') !!} - @@ -781,6 +784,46 @@ document.querySelectorAll('.btn-copy-inline').forEach(function (btn) { } }); }); + +function downloadPDF(btn) { + var originalHTML = btn.innerHTML; + btn.disabled = true; + btn.innerHTML = ' ' + (document.documentElement.lang === 'tr' ? 'Lütfen bekleyin...' : 'Please wait...') + ''; + + function run() { + var element = document.getElementById('letterheadPrintArea'); + var opt = { + margin: 0, + filename: 'truncgil-bank-accounts.pdf', + image: { type: 'jpeg', quality: 0.98 }, + html2canvas: { scale: 2, useCORS: true, letterRendering: true, scrollY: 0 }, + jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' } + }; + + html2pdf().set(opt).from(element).save().then(function() { + btn.disabled = false; + btn.innerHTML = originalHTML; + }).catch(function(err) { + console.error(err); + btn.disabled = false; + btn.innerHTML = originalHTML; + }); + } + + if (typeof html2pdf === 'undefined') { + var script = document.createElement('script'); + script.src = 'https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js'; + script.onload = run; + script.onerror = function() { + alert('PDF library could not be loaded. Please try again.'); + btn.disabled = false; + btn.innerHTML = originalHTML; + }; + document.head.appendChild(script); + } else { + run(); + } +} @endpush