How to auto-print Magento packing slips
Print a Magento or Adobe Commerce packing slip from an observer on the server. No PrintBase Magento module is included.
For Adobe Commerce and Magento teams shipping from a warehouse printer
Overview
Magento's packing slip is a PDF the admin can download. Printing it when a shipment is saved is an observer on sales_order_shipment_save_after, running in PHP on your server. PrintBase does not ship a Magento module.
Render or reuse the shipment PDF, base64 it, and POST content_type pdf to the warehouse printer_code. Multi-source inventory means the printer_code should follow the source or the stock, not a single global code, unless you really have one bench.
Idempotency-Key magento-slip-{shipmentId} handles the observer running more than once. The API key goes in env.php or an environment variable, not in a storefront block.
Integration steps
- 01
Observe shipment save
Server-side observer only. A storefront plugin must not see the API key.
- 02
Produce the PDF
Use the shipment PDF you already generate for email or admin download.
- 03
Choose printer_code by source
Map MSI source or warehouse code to a printer_code from GET /v1/printers.
- 04
POST pdf
Standard base64 content, copies 1, Bearer token, idempotency key.
- 05
Log the job on the shipment
Comments or a custom column with the job id help when the bench says nothing printed.
PHP
<?php
// Magento shipment observer: packing-slip PDF
$payload = [
'printer_code' => (int) getenv('PRINTER_CODE'),
'content_type' => 'pdf',
'content' => base64_encode($pdf),,
'copies' => 1,
];
$ch = curl_init('https://api.printbase.cloud/v1/print-jobs');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('PRINTBASE_API_KEY'),
'Content-Type: application/json',
'Idempotency-Key: ' . 'magento-slip-' . $shipmentId,
],
CURLOPT_POSTFIELDS => json_encode($payload),
]);
$body = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) >= 300) {
throw new RuntimeException($body);
}
$job = json_decode($body, true); // id, status=queued
Details for this setup
PDF path for a Magento packing slip
Use content_type pdf and exactly one of content (standard base64) or content_url (an http or https URL the agent can download). A private file must be fetched by your server and sent as base64, or exposed as a short-lived URL. On Windows the agent asks a PDF app to print to the named queue; if none is registered, the failure text names Adobe Reader or SumatraPDF as examples. macOS and Linux use lp.
Adobe Commerce is the same API
Hosted or self-hosted, the print call is identical. The agent still has to run in the warehouse, not inside Adobe's cloud.
Questions
Is there a Magento Marketplace extension?
No. You write the observer. The call is still POST /v1/print-jobs with a Bearer API key, and HTTP 201 means queued rather than printed.
Can I print the invoice PDF too?
Yes, as another job with its own key and, if needed, another printer_code.
The observer times out.
POST should return as soon as the job is queued. Do not wait for the physical printer inside the HTTP request that saves the shipment.
Multiple websites?
Same organization can hold many printers. Isolate brands with separate API keys and organizations if staff must not see each other's devices.
Free plan: 100 jobs a month on one computer, no card.