Hello,

I want to build a system that allows me to print a document (from a input field) and it prints at my home.
Basically, if I'm out I have an input box that if I upload a file to it, it will print for when I get home. Same if I was sat downstairs I didn't have to mess around with the networking with it.

My printer is always connected to the internet (via my network)

Is this possible, in php?

Dani AI

Generated

For : yes — you can build an “upload now, print at home later” flow, but the safe, reliable approaches depend on where your PHP runs and how you handle security and file conversion. The quick distinction to keep in mind (echoing points from and ) is whether the server that accepts uploads can directly reach the home printer, or whether the home network needs an agent to pull jobs.

A practical, production-friendly architecture

  • Host the upload UI on any PHP server (cloud or hosted).
  • Normalize and validate uploads on the server (prefer PDF as the canonical printable format).
  • Put jobs in a queue with metadata (filename, user, tried/failed attempts).
  • Run a small always-on agent on the home network (Raspberry Pi, NAS, PC). The agent polls the server over HTTPS, downloads queued jobs, converts if needed, prints locally via the platform print service, and reports status back. This avoids opening printer ports through NAT and reduces attack surface.

Minimal poller pseudocode example:

loop:
  job = GET /api/next-job (auth)
  if job:
    download job.file -> /tmp/job.pdf
    convert -> /tmp/printable.pdf   # if needed
    print_file("/tmp/printable.pdf")
    POST /api/job-complete (job.id, status)
  sleep N seconds

Practical tips and cautions

  • Convert Office/HTML to PDF server-side (LibreOffice headless, wkhtmltopdf, Ghostscript) so the printer sees a consistent format.
  • Limit allowed types and sizes, scan uploads, require authentication, use HTTPS and short-lived API keys.
  • Never expose raw printer ports (IPP 631, JetDirect 9100) to the open internet; prefer the poller or a VPN.
  • Test with small PDFs first and keep logs for troubleshooting.

References: CUPS documentation (local printing and drivers) and IPP/IPP Everywhere for modern network printing:

Recommended Answers

All 2 Replies

In php it is unreal.
You may generate a page for print on php and then use javascript to put the page on print.

Maybe you can. On linux the command lp permits you to print to a remote printer. So if the php script runs on a linux box and makes use of system() or exec() you can print, an example:

<?php
exec('lp -h 123.123.123.123 filename.txt');
?>

where is the remote ip of your printer. You'll probably have to convert some types of files before you can print them, check here:

- http://tldp.org/HOWTO/pdf/Printing-Usage-HOWTO.pdf

More reference:
- http://linux.about.com/od/itl_guide/a/gdeitl62t00.htm
-
- http://php.net/manual/en/function.exec.php

good luck! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.