Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

image to printer

Status
Not open for further replies.

KryptoS

Programmer
Feb 7, 2001
240
BE
Hello guys,

I'm making a barcode-system, for my stock. Making the barcode is working fine, but now I need to print it. The last thing I do is:

Code:
imagejpeg($this->im,$this->filename,$quality);

but how can I send this file directly to my printer. There is a function called 'printer_draw_bmp' that 'll do this. But my file is jpeg (or png, or something else, but not .bmp). Isn't there a function that will do the same like imagejpeg but to bmp?
I tried to convert the jpeg with the 'jpeg2wbmp' to bmp but that didn't work. Anyone an idea?
this is how I do it, but it isn't working...

Code:
// $_POST has my printer
$handle = printer_open($_POST['Printers']);
// get image height, width
list($width, $height, $type, $attr) = getimagesize("tmp/barcode/test.jpeg");
// jpeg to bmp? Something goes wrong here
jpeg2wbmp("tmp/barcode/test.jpeg","tmp/barcode/test.bmp",$height,$width,0);
// print bmp...
printer_draw_bmp($handle,"tmp/barcode/test.bmp",0,0,$width,$height);
printer_close($handle);

The One And Only KryptoS
 
ok I just discovered the 'imagewbmp' but it's still not outputting it right. So I can make png, jpeg files (those are correct) how can I send them to printer? Any suggestion is welcome

The One And Only KryptoS
 
which platform? printing is easier on windows. I'm not sure how to make it work on *nix but I guess you could get some results by playing around with sockets.
 
it's windows based...

The One And Only KryptoS
 
Yes I did, and that works fine...

how can I print my image now? It's a jpg-file (or png-file). Just can't figur it out. Printer_draw_bmp is only for bmp files...

Code:
printer_draw_bmp($handle,"tmp/barcode/test.bmp",0,0,$width,$height);

The One And Only KryptoS
 
I found another way for making barcodes...

I found a font-type for that. Now I can use that font for making my barcode and output that to my printer.

That must be something like this

Code:
$handle = printer_open("my printer");
printer_start_doc($handle, "My Document");
printer_start_page($handle);

$font = printer_create_font("Barcode39dc.ttf",70,60,PRINTER_FW_THIN,false,false,false,0);
printer_select_font($handle, $font);
printer_draw_text($handle, "000100020045", 40, 40);
printer_delete_font($font);

printer_end_page($handle);
printer_end_doc($handle);
printer_close($handle);

I put my file Barcode39dc.ttf in the windows font directory, and in the same directory on my webserver. But he's still not using it.... He only prints 00100020045.


The One And Only KryptoS
 
apologies but I cannot help you with this as I do not develop on a windows platform any more.

have you considered creating a pdf and then using a system call to launch acrobat and print the pdf to the printer of your choice? i.e. let the OS do the work from the command line and not php.
 
Yes, I did consider that :). That was one of my last options, or making a popup html, make a print with javascript and close the popup automatic. But these were my last options.

Anyway I think I found the solution. To make the barcode my script used 'imageline' to create the barcode-lines in an image. Instead I'm now using 'printer_draw_line', so the lines are send directly to my printer.

Thanks for the help...

The One And Only KryptoS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top