Latest News: (loading..)
Peper

Printing different printers

12 posts in this topic

Hello everyone

So i assume many shop owners prints a lot of different papers like packing slips, barcodes, waybills and and

So my question is there a way to specify which printer to use by default depending on filename or form or page size.
So instead of the popup window when ctl p or print button is pressed, no input needed to select correct printer and fiddles - automates. Not silent printing

Even if in the admin side viewing document first, any way to list available printers locally and on shared network using html, show available printers or rather specific - select printer - mouse click and print.

Please post if you know something in this line, there was some PHP functions but seems that was deprecated and dropped entirely.

 

 

Share this post


Link to post
Share on other sites

I don't think I've ever seen an application that went directly to the printer when I pressed the Print button, without a dialog asking for the printer to be used, and its settings. That includes word processors, browsers, mail clients, and PDF readers. They use OS/windowing services to select the printer. About the best you could probably do is to write the output to a temporary file, and then under the covers, batch submit it (via command line) to a printer. You might, under your OS, be able to associate custom printer names for different paper trays and modes on one printer, as well as for physically separate printers. Or, the command could specify the paper tray, landscape/portrait, etc.

Would it be adequate to still have a print dialog, but have everything prefilled/preselected based on which queue you sent to? Is that what you're asking for? That gives you a chance to recover if the printer went down, ran out of paper or ink, or otherwise had problems. Then it's normally just one "go ahead and print the thing" button click. Your OS might have a print dialog that you could invoke from your store application, along with pre-setting all the choices. It might even have the ability to accept the file on a socket or pipe, so that you don't have to write a file first. Naturally, all this is going to be very OS-dependent, but it might be possible to put some hooks into osC to help with the process.

Just some random thoughts... I'd like to hear the thoughts of others (I'll take off my tinfoil hat, first!).

Share this post


Link to post
Share on other sites

@Peper

A quick Google search came up with these. Do any of these help?

http://docs.php.net/manual/da/function.printer-set-option.php

http://php.net/manual/fa/function.printer-set-option.php

However, as @MrPhil mentioned, you are administering your store through a Browser, and all printing functions *should* be handled by your browser, and/or by the OS on your workstation. Most 'properly coded' software hands off the printing functions to the local OS (although, Micro$oft is notorious for bypassing its own rules in cases like this).

Malcolm

Share this post


Link to post
Share on other sites

Have you tried using a macro program?.  Record your macro and call it from your php script.  That might do it. 

Dan

Share this post


Link to post
Share on other sites

While researching this, i got sidetracked 

<body bgcolor="chucknorris"> test </body>

Will give red background and so a few similar other examples

Did not know that!

 

Share this post


Link to post
Share on other sites
10 hours ago, Peper said:

While researching this, i got sidetracked 

You sure did. :biggrin: 

Dan

Share this post


Link to post
Share on other sites

@Peper

For windows only:
https://github.com/maryo/php-5.5-windows-extensions/tree/master/php_printer-0.1.0-dev-5.5-vc11-x86

I once made : https://github.com/osc2nuke/ZEBRA-PHP-SAMPLE-RECEIPT

Also can use: https://github.com/osc2nuke/PHP-Printer

It is fun to work with.

Keep in mind that some printers require knowledge of the CPCL , 

For example in the git's zebra repository :

! U1 JOURNAL

! U1 SETLP 5 2 46 

etc etc ( i cannot even remember what that does)

Edited by wHiTeHaT

Share this post


Link to post
Share on other sites

@wHiTeHaT

The printers can only print if it is printed on the same server machine as far as i could find out - php_printer.dll.

Also this was removed from newer versions Apache PHP

Seems this cant be done or there is no easy way :sad:

this will error:  $handle=printer_open("EPSON LX-300"); 

printer_open  Opens a connection to a printer

(PECL printer SVN)

PHP Fatal error:  Call to undefined function printer_open() in /home/---/--/----/courier_print.php on line 39

 

Share this post


Link to post
Share on other sites

@Peper

you require the printer.dll from the first link.

you can send request from website to any pc where this dll is installed in association with php 5.5

 

perhaps this is more helpfull:

http://www.nongnu.org/phpprintipp/

Edited by wHiTeHaT

Share this post


Link to post
Share on other sites

@wHiTeHaT As far as I understand this, the PHP code cannot do this at client side

I have to install the php 5.5 version first on another pc to further test, currently running php 7.1.9 (Zend: 3.1.0)

Just now busy checking and deciphering whats is needed and happening here

<?php 
$tmpdir = sys_get_temp_dir();   # ambil direktori temporary untuk simpan file.
$file =  tempnam($tmpdir, 'tmp');  # nama file temporary yang akan dicetak
$handle = fopen($file, 'w');
$condensed = Chr(27) . Chr(33) . Chr(4);
$bold1 = Chr(27) . Chr(69);
$bold0 = Chr(27) . Chr(70);
$initialized = chr(27).chr(64);
$condensed1 = chr(15);
$condensed0 = chr(18);
$Data  = $initialized;
$Data .= $condensed1;
$Data .= "==========================\n";
$Data .= "|     ".$bold1."OFIDZ MAJEZTY".$bold0."      |\n";
$Data .= "==========================\n";
$Data .= "Ofidz Majezty is here\n";
$Data .= "We Love PHP Indonesia\n";
$Data .= "We Love PHP Indonesia\n";
$Data .= "We Love PHP Indonesia\n";
$Data .= "We Love PHP Indonesia\n";
$Data .= "We Love PHP Indonesia\n";
$Data .= "--------------------------\n";
fwrite($handle, $Data);
fclose($handle);
copy($file, "//localhost/EPSOM LX-300");  # Lakukan cetak
unlink($file);
?>

 

Share this post


Link to post
Share on other sites

That's what i'm saying....

you van build up a string....or even upload the file to that machine

Send this string or upload file to a server what runs on windows machine and have the printer dll installled

if $_REQUEST    action=print&filename=myfile

if action == $_GET['print'] && file_exists('myfile.???') 
do............

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now