+ Post New Thread
Results 1 to 2 of 2
Web Development Thread, Print to printer in Coding and Web Development; Hi All, Does anyone know a way to print directly to a printer using PHP? So far I've been using ...
  1. #1
    bladedanny's Avatar
    Join Date
    May 2009
    Location
    Sheffield
    Posts
    590
    Thank Post
    99
    Thanked 81 Times in 58 Posts
    Rep Power
    36

    Print to printer

    Hi All,

    Does anyone know a way to print directly to a printer using PHP? So far I've been using javascript:
    Code:
    window.print()
    Which does print what I want it to but displays the print dialog box.

    I'd like it to go straight to either the client default printer or to a printer attached to the webserver.

    Thanks,

    Dan

  2. IDG Tech News

  3. #2
    bladedanny's Avatar
    Join Date
    May 2009
    Location
    Sheffield
    Posts
    590
    Thank Post
    99
    Thanked 81 Times in 58 Posts
    Rep Power
    36
    Hi All,

    After some playing around with PHP and Shell I've used the following method that works quite well. I thought I'd post it on here for others if they ever needed it.

    PHP Code:
    shell_exec('lpr -P $Printer $file'); 
    Which basically prints $file to $printer (that is a printer installed on the server.)

    Dan

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 9
    Last Post: 21st March 2011, 09:58 AM
  2. "sent to printer" but not printing
    By dave.81 in forum Windows
    Replies: 11
    Last Post: 18th March 2008, 04:21 PM
  3. Replies: 14
    Last Post: 22nd November 2006, 10:33 AM
  4. Replies: 9
    Last Post: 24th November 2005, 03:21 PM
  5. Print to PDF
    By mark in forum Windows
    Replies: 13
    Last Post: 23rd November 2005, 02:03 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •