Direct Printing for Laravel Apps


August 6th, 2020

Laravel Printing is a package by Randall Wilk that allows your web application to send PDF documents or raw text from a remote server to a printer on your local network.

At the time of writing this package supports a PrintNode driver (with others planned) to power the communication between your web application and printers. If your mind is still trying to make sense of how this works, here’s an example of how the code looks:

$printJob = Printing::newPrintTask()

// the id number returned from the print server

Here are some cool things you can do with this package:

// List all printers

// Find a specific printer

// Getting the configured default printer and printer ID

If you have a receipt printer you can print them with the provided ReceiptPrinter class:

$text = (string) (new ReceiptPrinter)
    ->text('My heading')
    ->twoColumnText('Item 1', '2.00')
    ->twoColumnText('Item 2', '4.00')

    ->content($text) // content will be base64_encoded if using PrintNode

You can learn more about this package, get full installation instructions, and view the source code on GitHub at rawilk/laravel-printing.

This package was submitted to our Laravel News Links section. Links is a place the community can post packages and tutorials around the Laravel ecosystem. Follow along on Twitter @LaravelLinks

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.