# easy-invoice/2.3.3/includes/Helpers/PdfHelper.php

Easy Invoice – Invoice Generator, PDF Quotes &amp; Payments, version 2.3.3. 89 lines.

- Page: https://pluginprobe.com/plugins/easy-invoice/2.3.3/code/includes/Helpers/PdfHelper.php
- Raw: https://pluginprobe.com/plugins/easy-invoice/2.3.3/raw/includes/Helpers/PdfHelper.php
- Modified: 2025-08-24T10:24:48+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/easy-invoice/2.3.3/code/includes/Helpers/PdfHelper.php#L10-L20`.

```php
<?php
/**
 * PDF Helper Class
 *
 * @package Easy_Invoice
 * @subpackage Helpers
 */

namespace EasyInvoice\Includes\Helpers;

use EasyInvoice\Models\Invoice;

/**
 * PDF Helper Class
 *
 * Handles PDF generation for invoices with styling consistent with the web view
 */
class PdfHelper {

    /**
         * Get invoice data for PDF generation
         * @param \EasyInvoice\Includes\Models\Invoice $invoice
         * @return array
         */
        public static function getInvoiceDataForPdf($invoice) {
            $company = [
                'name' => get_bloginfo('name'),
                'address' => get_option('easy_invoice_company_address'),
                'email' => get_option('easy_invoice_company_email'),
                'phone' => get_option('easy_invoice_company_phone')
            ];

            $customer = [
                'name' => $invoice->getCustomerName(),
                'address' => $invoice->getCustomerAddress(),
                'email' => $invoice->getCustomerEmail()
            ];

            $items = [];
            foreach ($invoice->getItems() as $item) {
                $items[] = [
                    'name' => $item->getName(),
                    'description' => $item->getDescription(),
                    'quantity' => $item->getQuantity(),
                    'price' => $item->getPrice(),
                    'adjust' => $item->getAdjust(),
                    'total' => $item->getAmount()
                ];
            }

            $totals = [
                'subtotal' => $invoice->getSubtotal(),
                'tax' => $invoice->getTaxAmount(),
                'discount' => $invoice->getDiscountAmount(),
                'total' => $invoice->getTotal()
            ];

            return [
                'number' => $invoice->getNumber(),
                'date' => $invoice->getIssueDate(),
                'dueDate' => $invoice->getDueDate(),
                'status' => $invoice->getStatus(),
                'company' => $company,
                'customer' => $customer,
                'items' => $items,
                'totals' => $totals,
                'notes' => $invoice->getNotes(),
                'currency_code' => $invoice->getCurrencyCode() ?: 'USD',
                'currency_symbol' => \EasyInvoice\Helpers\CurrencyHelper::getCurrencySymbol($invoice->getCurrencyCode() ?: 'USD'),
                'symbol_position' => get_option('easy_invoice_currency_symbol_position', 'before'),
                'template' => $invoice->getTemplate() ?: 'standard'
            ];
            }

        /**
         * Enqueue required scripts for PDF generation
     */
        public static function enqueuePdfScripts() {
            // Enqueue jsPDF
            wp_enqueue_script(
                'jspdf',
                'https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js',
                [],
                '2.5.1',
                true
            );
        }
    }

```
