7

I need a way to capture everything that is printed in my notebook.

Why?

I have a system, in PHP, and sometimes I need to print (php_printer) some invoices, but this costs a lot paper.

Printing is sent in the background without any popup windows for user confirmation.

So every time I send something to the printer, the windows (or any application) show me what was sent; or generate a PDF.

The problem is: How can I use this 'alternativa' without changing the printer (driver, etc). Because, if I do that, I need to test in 2 printers, and you know what I mean.

EscPos

This is the file that I used to print in windows or linux. I develop in windows (requirement of the company) but publish it in a linux server.

gist: https://gist.github.com/patrickmaciel/7673875

What I want

To capture every printed file and save it in a PDF or some driver/application in order to not print the file but rather show it to me on the screen (windows).

Setup

Dev OS (my): Windows 7 (Yes I know, but my employee only works with windows)
Prod OS: CentOS
Printer: TM-T88IV AFU (Epson)

Superdooperhero
  • 7,584
  • 19
  • 83
  • 138
Patrick Maciel
  • 4,874
  • 8
  • 40
  • 80
  • You want to print **and** pdf? or pdf **instead** printing? – MeNa Nov 26 '13 at 19:05
  • @MeNa print without change my method but capture in background the printed files and save in pdf or show for me in a window, or in another way. – Patrick Maciel Nov 26 '13 at 19:23
  • little change in your code is not an option? i mean, create a pdf with php is not very hard... – MeNa Nov 26 '13 at 19:30
  • @MeNa Maybe, but I no have idea how to create a PDF file of a POS printer. Fox example, in same size, like a receipt. – Patrick Maciel Nov 26 '13 at 19:55
  • For now are you generate an invoice and send it to php_printer? what is the invoice when you send it to printer? and how do you generate it? – MeNa Nov 26 '13 at 20:09
  • Could you give us some more background info on how your POS system creates the print job? In some cases capturing and saving a printer spool file may be possible but that highly depends on printers, OS and how a print job is triggered. Could you try to locate the PHP print script? – SaschaM78 Nov 27 '13 at 09:29
  • @SaschaM78 I add more informations about. – Patrick Maciel Nov 27 '13 at 10:58
  • @MeNa everything is generate and manipulate with PHP and after sent to printer with EscPos file using php_printer (windows) or lpr/cups (linux). – Patrick Maciel Nov 27 '13 at 10:59
  • Have a look at your Output() function starting in line 1069, if you'd add `file_put_contents('/PATH/TO/OUTPUT/FILE', $this->document);` around line 1072 you'd save a copy of each file printed. – SaschaM78 Nov 27 '13 at 11:05
  • It seems as if there is no Epson->PDF solution at hand, after implementing the mentioned change and having printed a test print, could you post the contents of the created file? That'll help understand the format used and may lead to a solution. – SaschaM78 Nov 27 '13 at 11:18
  • @SaschaM78 I'll try what you say... – Patrick Maciel Nov 27 '13 at 11:23
  • @SaschaM78 Doesn't work but I create a new action and execute a second operation after print because I think not exist any solution for my problem (monitoring printings in background). Anyway, thanks for your time. – Patrick Maciel Nov 27 '13 at 15:38

1 Answers1

1

To my question apparently no solution.

So I just edited it with the class and EscPos.php added a method to be executed after printing, writing a simplified way to print invoice in a txt file, which I monitor after filename.txt command tail-f.

Solution code: https://gist.github.com/patrickmaciel/7677891

Thanks guys.

Patrick Maciel
  • 4,874
  • 8
  • 40
  • 80