The Home for Magento 2 Excellence

Automated build tests for Magento 2 modules. Explore. Evaluate. Elevate. #magento2

1062 Modules
673 Ready
388 Need Help
Vendors 🏆 Leaderboard
Stable v1.1.0 OSL-3.0, AFL-3.0

Print Invoice API

steveb27/printinvoice 20

Exposes a REST API endpoint to retrieve printable invoice PDFs as base64-encoded data, extending the native Magento invoice API.

2
Downloads
Below average
0
GitHub Stars
9mo ago
Last Release
0
Open Issues
Build Issues
0/3 checks passed

Build Tests

Composer Install
– DI Compile
– Templates

Code Quality

CS Coding Standard
PHPStan Failed

Release Discipline

Follows SemVer · 100% What is this?

Release history audited up to v1.1.0

Tested on Magento 2.4.9

Recent Test History

Each release is tested against the latest Magento version at that time.

v1.1.0 on Magento 2.4.9
May 27, 2026
v1.1.0 on Magento 2.4.8-p4
Mar 22, 2026
v1.0.2 on Magento 2.4.8-p4
Mar 22, 2026

Looking for Contributors

Composer installation fails. Your contribution could help the entire Magento community!

Contribute

Share This Module's Status

Print Invoice API Magento compatibility status badge

README

Loaded from GitHub

PrintInvoice User Guide

Overview

PrintInvoice is an extension for Magento that adds a REST API endpoint to generate invoice PDFs programmatically. The PDF is generated on demand using Magento's native invoice rendering logic and does not require any interaction with the Magento Admin.

The extension does not introduce configuration settings, frontend components, or backend UI changes.


Installation

  1. Install the extension using Composer.

  2. Run the following Magento commands:

    bin/magento setup:upgrade bin/magento cache:flush

No additional configuration is required.


Configuration

This extension does not provide any configuration options.

There are:

  • No Admin settings
  • No frontend components
  • No system configuration entries
  • No additional database setup beyond installation

The API endpoint becomes available immediately after installation.


API Endpoint

Method: GET

Endpoint:

/rest/{store_code}/V1/invoices/{invoiceId}/print

Example (default store view):

/rest/default/V1/invoices/1/print

Required Parameter

Parameter Required Type Description
id required integer The invoice ID

Authentication

This endpoint requires standard Magento REST API authentication.

You may use:

  • Admin token
  • Integration token
  • OAuth

Example Authorization Header:

Authorization: Bearer <access_token>

Step-by-Step Usage Example

Step 1: Obtain an Admin Token

Request:

POST /rest/V1/integration/admin/token

Body:

{
  "username": "admin",
  "password": "admin_password"
}

Response:

<access_token>

Step 2: Request the Invoice PDF

GET /rest/default/V1/invoices/1/print
Authorization: Bearer <access_token>

Step 3: Example API Response

{
  "id": 1,
  "pdf": "JVBERi0xLjQKJc..."
}
  • id --- Invoice ID
  • pdf --- Base64-encoded PDF content

Step 4: Decode the PDF

Example in PHP:

$response = json_decode($apiResponse, true);
file_put_contents('invoice.pdf', base64_decode($response['pdf']));

Expected Behavior

  • The PDF is generated on demand.
  • The output matches the invoice PDF format used by Magento.
  • No manual Admin action is required.
  • The invoice does not need to be previously printed.

Notes

Screenshots may demonstrate requests using Postman for testing purposes. Any REST client capable of making authenticated Magento API requests may be used.


Compatibility

  • Magento Open Source
  • Adobe Commerce

This content is fetched directly from the module's GitHub repository. We are not the authors of this content and take no responsibility for its accuracy, completeness, or any consequences arising from its use.