<?php
// Enqueue PDF scripts
EasyInvoice\Includes\Helpers\PdfHelper::enqueuePdfScripts();
?>

<div class="wrap">
    <h1>Invoice #<?php echo esc_html($invoice->getNumber()); ?></h1>
    
    <div class="invoice-actions">
        <button type="button" class="button button-primary" id="generate-pdf">
            Download PDF
        </button>
    </div>

    <!-- Rest of your invoice view template -->
</div>

<script>
document.addEventListener('DOMContentLoaded', function() {
    const generatePdfButton = document.getElementById('generate-pdf');

    generatePdfButton.addEventListener('click', function() {
        // Use the new PDF generator that captures HTML directly
        if (typeof InvoicePdfGenerator !== 'undefined') {
            const pdfGenerator = new InvoicePdfGenerator();
            pdfGenerator.generatePDF();
        } else {
            alert('PDF generator not available');
        }
    });
});
</script> 