PrintBase
  • Product
  • Pricing
  • Docs
  • Resources
PrintBase/Guides/Print from your language or framework

Print PDF invoices from Laravel

Render a Laravel invoice PDF with Dompdf or Snappy, then POST the bytes. The office printer is selected by printer_code.

For Laravel billing code that should also print

Overview

You already render invoice PDFs for email. The print path takes those same bytes. Dompdf's output(), a Snappy temporary file, or a stored invoice on disk all end as base64 content with content_type pdf.

Send the office printer's code, which may differ from a warehouse label printer. options can include duplex. The driver may ignore it; check one page.

Email and print are two side effects. A failed print should not roll back a sent email unless your business rule says so. Store the job id on the invoice either way.

Integration steps

  1. 01

    Create an API key on the server

    Use an API key (pb_live_…) in the process environment. Authorization is Bearer. Do not ship the key to browsers or mobile apps.

  2. 02

    Install the agent beside the printer

    Windows, macOS, or Linux. GET /v1/printers and keep the numeric code.

  3. 03

    POST /v1/print-jobs

    content_type is pdf or raw. Send exactly one of content (standard base64) or content_url.

  4. 04

    Reuse the idempotency key on retry

    A new key means a second physical print. HTTP 409 means the same key was reused with a different body.

  5. 05

    Read the job before you tell the user

    GET /v1/print-jobs/{id}. Paid plans can also receive print_job.completed and print_job.failed webhooks.

PHP

<?php
// Laravel invoice 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: ' . 'inv-'.$invoice->id,
    ],
    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

Render first

If the PDF is blank, fix the view. The API will faithfully print a blank page. The agent prints only what you send; it does not fetch the document from the platform for you.

Do not pass a signed route as content_url unless the agent can fetch it

Laravel signed URLs that require cookies will fail in the agent with DOWNLOAD_FAILED. Prefer base64 for private invoices.

Questions

Which PDF library?

Any that gives bytes. The print API does not integrate a specific one.

Queue the print?

Yes. Implement ShouldQueue and keep the idempotency key as the invoice number.

Multi-tenant printer?

Look up printer_code on the team model. Do not share one code across tenants that have their own offices.

Duplex? in this setup

Pass options.duplex. Confirm on the device. It is not enforced by the API.

Related guides

  • Print Laravel receipts from shared hosting

    Laravel on shared hosting can still print. The host only makes HTTPS. The receipt printer stays in the shop behind the agent.

  • How to auto-print Shopify invoice PDFs

    Send an invoice PDF you generate for a Shopify order to a local office printer through the print-jobs API. No Shopify invoice plugin is included.

  • Print a PDF from Flask

    Flask can post a PDF with urllib in the request that generates it. Keep the API key in the environment. There is no Flask extension to install.

  • Print a PDF from Python

    Use the Python standard library to POST a base64 PDF. No extra print package is required. The agent prints it on the computer you chose.

Free plan: 100 jobs a month on one computer, no card.

Create a free accountRead the API docs
PrintBase

PrintBase connects your applications to physical printers anywhere - securely, reliably, and in real time.

Product
Receipt PrintingLabel PrintingDashboardDevicesWebhooks
Resources
DocsBlogStatusAPI ReferenceDownloadPrintBase vs PrintNodePrintNode PricingFAQ
Guides
All guidesIntegrationsPrintersCode samplesComparisonsUse casesTroubleshooting
Company
ContactSecurityPrivacy

© 2026 Aveniq Technologies OÜ. All rights reserved. PrintBase is a service of Aveniq Technologies OÜ.

PrivacyTermsRefunds