Trying to print out a label directly from my app (localhost) to a printer on my computer. So far i've got this: It's not throwing up any errors but is not printing out. Could anyone shed any light on this. Thanks. function test_print() { $pHandle = fopen("./pdf_print/test.pdf", "r"); $handle = printer_open("DYMO LabelWriter 400"); if(!$handle || $handle == NULL) { die('Error connecting to Printer'); } else { printer_set_option($handle, PRINTER_MODE, "raw"); printer_write($handle,$pHandle); printer_close($handle); } } Code (markup):
printer_set_option($handle, PRINTER_MODE, "raw"); taken this line out and something prints, but i get resource id#44 instead of the the pdf?
Have you tried to make a simple test of the code? Just this: <? $handle = printer_open("DYMO LabelWriter 400"); printer_write($handle,"Test label"); printer_close($handle); ?> Does this work (I haven't tested it).
cheers elias. It seems to be finding the printer and printing, but it's not printing the file just the printing the error resource id #44. I did this to check file was ok. $pHandle = fopen("./pdf_print/test.pdf", "r+"); if(!$pHandle || $pHandle == NULL) { die('Cant find file'); } $handle = printer_open("DYMO LabelWriter 400"); if(!$handle || $handle == NULL) { die('Error connecting to Printer'); } else { printer_write($handle,$pHandle); printer_close($handle); } Code (markup):
This can be easily explained. Take a look at the following lines. printer_write($handle,$pHandle); PHP: $pHandle = fopen("./pdf_print/test.pdf", "r+"); PHP: As you can see, you forgot to read the file - you've only opened it. The following should work. printer_write($handle, fread($pHandle, filesize("./pdf_print/test.pdf"))); PHP: