{"id":18311095,"url":"https://github.com/quickshiftin/php-pdf-invoice","last_synced_at":"2025-08-20T19:19:11.359Z","repository":{"id":62532166,"uuid":"83368005","full_name":"quickshiftin/php-pdf-invoice","owner":"quickshiftin","description":"Create PDF invoices for your customers with PHP","archived":false,"fork":false,"pushed_at":"2023-09-03T22:02:24.000Z","size":1730,"stargazers_count":14,"open_issues_count":2,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-13T19:00:12.067Z","etag":null,"topics":["invoice","pdf","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/quickshiftin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-27T23:32:50.000Z","updated_at":"2025-04-19T18:31:13.000Z","dependencies_parsed_at":"2025-04-05T18:46:51.917Z","dependency_job_id":null,"html_url":"https://github.com/quickshiftin/php-pdf-invoice","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/quickshiftin/php-pdf-invoice","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quickshiftin%2Fphp-pdf-invoice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quickshiftin%2Fphp-pdf-invoice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quickshiftin%2Fphp-pdf-invoice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quickshiftin%2Fphp-pdf-invoice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/quickshiftin","download_url":"https://codeload.github.com/quickshiftin/php-pdf-invoice/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quickshiftin%2Fphp-pdf-invoice/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271370293,"owners_count":24747802,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-20T02:00:09.606Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["invoice","pdf","php"],"created_at":"2024-11-05T16:16:25.218Z","updated_at":"2025-08-20T19:19:11.323Z","avatar_url":"https://github.com/quickshiftin.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP PDF Invoice\nThis project uses a PDF invoice generator extracted from Magento for general use via Composer. You can easily integrate your existing domain model and start generating PDF invoices that look like this:\n\n![Example Invoice PDF](http://i289.photobucket.com/albums/ll238/quickshiftin/php-pdf-invoice-example_zpswiumm9tg.png)\n\n## Features\n* Generate Invoice PDF documents\n* Integrate your domain model easily by implementing Order and OrderItem interfaces\n* Composer distribution\n* Change background and font colors, font types, line color and provide custom logo\n* Automatically create multiple pages based on number of line items\n\n## Install via Composer\n\n`./composer.phar require quickshiftin/php-pdf-invoice`\n\n## Usage\n### Integration boilerplate - connecting your existing domain model to the generator\nTo integrate your existing application's orders, simply provide two classes that `implement` `Quickshiftin\\Pdf\\Invoice\\Spec\\Order` and `Quickshiftin\\Pdf\\Invoice\\Spec\\OrderItem`\n\n#### OrderItem interface implementation\n```php\nnamespace MyApp;\nuse Quickshiftin\\Pdf\\Invoice\\Spec\\OrderItem;\n\n// Implement the Order Item methods below\nclass MyOrderItem interface implements OrderItem\n{\n    /**\n     * The name or description of the product\n     * @return string\n     */\n    public function getName();\n\n    /**\n     * The 'SKU' or unique identifier for your product\n     * @return string\n     */\n    public function getSku();\n\n    /**\n     * The quantity sold\n     * @return int\n     */\n    public function getQuantity();\n\n    /**\n     * The price per unit\n     * @return float\n     */\n    public function getPricePerUnit();\n\n    /**\n     * The price including tax\n     * @return flaot\n     */\n    public function getPrice();\n\n    /**\n     * The sales tax amount in dollars\n     * @return float\n     */\n    public function getSalesTaxAmount();\n}\n```\n#### Order interface implementation\n```php\nuse Quickshiftin\\Pdf\\Invoice\\Spec\\Order;\n\n// Implement the order methods below\nclass MyOrder implements Order\n{\n    /**\n     * Get the sub-total, eclusive of shipping and tax.\n     * @return float\n     */\n    public function getPriceBeforeShippingNoTax();\n\n    /**\n     * Get the shipping charge if any\n     * @return float\n     */\n    public function getCustomerShipCharge();\n\n    /**\n     * Get the sales tax amount, eg .08 for 8%\n     * @return float\n     */\n    public function getSalesTaxAmount();\n\n    /**\n     * Get the total cost including shipping and tax\n     * @return float\n     */\n    public function getTotalCost();\n\n    /**\n     * Get the full billing address for the customer\n     * @return string\n     */\n    public function getFullBillingAddress();\n\n    /**\n     * Get the payment method, EG COD, Visa, PayPal etc\n     * @return string\n     */\n    public function getPaymentMethod();\n\n    /**\n     * Get the full shipping address for the order\n     * @return string\n     */\n    public function getFullShippingAddress();\n\n    /**\n     * Get the name of the shipping method, EG UPS, FedEx, etc\n     * @return string\n     */\n    public function getShippingMethodName();\n\n    /**\n     * Get an array of OrderItem objects\n     * @note This should return an array of instances of a class where you implement Quickshiftin\\Pdf\\Invoice\\Spec\\OrderItem\n     * @return array\n     */\n    public function getOrderItems();\n\n    /**\n     * Get the id of the order\n     * @return int|string\n     */\n    public function getOrderId();\n\n    /**\n     * Get the date of the sale\n     * @return DateTime\n     */\n    public function getSaleDate();\n}\n```\n\n### Implementation suggestion\nSince these are `interface`s, you can create a new class that wraps your existing OrderItem objects. If there are no name collisions you could also consider implementing directly on your existing OrderItem class.\n\n\n### Building \u0026 Styling your Invoice PDFs\nThis system uses [`Zend_Pdf`](https://framework.zend.com/manual/1.10/en/zend.pdf.html) (from ZF1) under the hood. The package provides `Quickshiftin\\Pdf\\Invoice\\Factory` which is a wrapper for instantiating classes from `Zend_Pdf`. You'll use these objects to customize the appearance of your PDFs.\n\nWe also assume you have an instance of an order object which implements `Quickshiftin\\Pdf\\Invoice\\Spec\\Order` as described above that is stored in a variable called `$myOrder`.\n\n```php\nuse Quickshiftin\\Pdf\\Invoice\\Invoice as PdfInvoice;\nuse Quickshiftin\\Pdf\\Invoice\\Factory as InvoiceFactory;\n\n$oInvoiceFactory = new InvoiceFactory();\n$oInvoicePdf     = new PdfInvoice();\n\n// Configure fonts - just put ttf font files somewhere your project can access them\n$oInvoicePdf-\u003esetRegularFontPath(__DIR__ . '/../assets/Arial.ttf');\n$oInvoicePdf-\u003esetBoldFontPath(__DIR__ . '/../assets/Arial Bold.ttf');\n$oInvoicePdf-\u003esetItalicFontPath(__DIR__ . '/../assets/Arial Italic.ttf');\n\n// Set Colors\n$red    = '#d53f27';\n$yellow = '#e8e653';\n\n// Title section of invoice\n// Background color for title section of invoice, the default is white\n$oInvoicePdf-\u003esetTitleBgFillColor($oInvoiceFactory-\u003ecreateColorHtml($yellow));\n$oInvoicePdf-\u003esetTitleFontColor($oInvoiceFactory-\u003ecreateColorHtml('black'));\n\n// Header sections of invoice\n$oInvoicePdf-\u003esetHeaderBgFillColor($oInvoiceFactory-\u003ecreateColorHtml($red));\n$oInvoicePdf-\u003esetBodyHeaderFontColor($oInvoiceFactory-\u003ecreateColorHtml('white'));\n\n// Body section of invoice\n$oInvoicePdf-\u003esetBodyFontColor($oInvoiceFactory-\u003ecreateColorHtml('black'));\n\n// Line color of invoice\n$oInvoicePdf-\u003esetLineColor($oInvoiceFactory-\u003ecreateColorGrayscale(0));\n\n// Configure logo\n$oInvoicePdf-\u003esetLogoPath(__DIR__ . '/../assets/fake-logo.jpg');\n\n// Build the PDF\n// $oPdf is an instance of Zend_Pdf\n$oPdf = $oInvoicePdf-\u003egetPdf($myOrder);\n\n// A string rendition, you could echo this to the browser with headers to implement a download\n$pdf = $oPdf-\u003erender();\n\n// You can also simply save it to a file\nfile_put_contents('/tmp/test.pdf', $pdf);\n```\n\n## Notes\nYou can look at the test directory for usage insights. Issues and PRs welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquickshiftin%2Fphp-pdf-invoice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquickshiftin%2Fphp-pdf-invoice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquickshiftin%2Fphp-pdf-invoice/lists"}