Printing to a printer connected to the server

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
zumbrujm
Forum Newbie
Posts: 2
Joined: Fri Jul 10, 2009 3:08 pm

Printing to a printer connected to the server

Post by zumbrujm »

Hello,

Summary:
I am attempting to process a form, use that information to create a product label, and then have that label printed.

Background: My plan is to have the receiving dept. fill in all the details for incoming raw materials using a web browser form. When they click submit it will send the form to the server, where the data will be processed. Right now I'm planning on using FPDF to generate a pdf of the label. Then, I will have the server print to the label printer via a really long printer cable, or by hooking the printer to a workstation and sharing it over the network. The server is running phpMyadmin on Ubuntu 9.04, and the clients will be running XP.

Questions:
1. Is pdf creation the best method for making a product label with PHP?

2. Using FPDF there appears to be an option for setting the page size. What am I doing wrong here?

$pagesize=array();
$pagesize[0]='3';
$pagesiez[1]='4';
$pdf=new PDF('P','in',$pagesize);

http://fpdf.org/en/doc/addpage.htm

3. The PHP Printer functions only work on Windows, so how do I print this from the server? Would this require a different language than PHP?

Thanks for the help, I really appreciate any direction, or guidance on places to look.
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Printing to a printer connected to the server

Post by McInfo »

Are you missing an "F" before "PDF"? Should the dimensions be given as numbers rather than strings?

Code: Select all

$pdf = new FPDF('P', 'in', array(3, 4));
It seems to me that printing is something that should be attended rather than automated. Maybe you can save the PDFs to a directory and have someone manually print them periodically.

Edit: This post was recovered from search engine cache.
Last edited by McInfo on Wed Jun 16, 2010 2:48 pm, edited 1 time in total.
zumbrujm
Forum Newbie
Posts: 2
Joined: Fri Jul 10, 2009 3:08 pm

Re: Printing to a printer connected to the server

Post by zumbrujm »

When I switched to declaring the page size variables as numbers instead of strings, it started working.

I really want to have printing automated. The printer extension of php seems to be working really well for me. I wish there was a similar extension that worked for both linux and windows.

Thanks for the help.

John
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Printing to a printer connected to the server

Post by McInfo »

You could find or write a command-line program (written in C perhaps) to do the printing and call it from PHP using exec() or system().

PHP Manual: System program execution

Edit: This post was recovered from search engine cache.
Post Reply