Follow these steps in order to get POSprint set up properly:
- Download the entire project directory from the POS-Print-Files repo.
- Install printer driver software from
SPRT DriverV2.0
directory- First, Un-zip the folder
- Navigate to
/English
->/Printer Driver
- Install the executable (right-click, then select run as admin) that should be used for your computer, depending on your Windows operating system.
- On Devices and Printers, you will probably see 2 devices (1 printer, 1 unknown device when printer plugged in)
- In order to see the new printer under the "Printer" category, you may have to wait a while, or restart your computer.
- Printer model = 80 Series (POS88V)
- Make sure printer is shared - remember the shared name
- Go to Devices and Printers again
- Add a Printer
- New -> Use existing Port (USB001)
- Generic -> Generic / Text Only
- Use driver already installed (from step #1)
- Name & share the printer something like
SPRT POS Printer
- Install Python 2.7.12 on your computer and can be accessed from the folder (add to PATH)
- Note: Make sure you're installing the correct version of Python! This has only been tested with v2.7.12
- PHP doesn't need to be 'installed', just some files need to be configured
- Edit the php.ini file - make sure extension_dir points to the correct directory of extensions
- Edit the php.ini file - uncomment the line 'extension=php_mbstring.dll' so that the php script can use that extension
- Edit the POSprint.php file - make sure line 16 has same name of printer created in step 2 (probably 'SPRT POS Printer')
- You may have to install microsoft redistributable packages if you don't have microsoft visual studio already installed on your machine.
- I've had some trouble and some success using the redistributable packages, so I often just installed the full program.
- Important Step: Copy all of the files starting with
POSprint
into the folder calledCODE_GOES_HERE
.- You should only need to download the printer driver and all of the python / php installers one time. However, if some code updates come out for the POSprint files, the updated files always need to be place inside the
POSprint
directory. - After you move all of the POSprint... files into
/CODE_GOES_HERE
, you may want to make sure they don't also exist anywhere else, just to avoid confusion later.
- You should only need to download the printer driver and all of the python / php installers one time. However, if some code updates come out for the POSprint files, the updated files always need to be place inside the
Now you're ready to go? This is how you should run the program:
- Navigate into your
/CODE_GOES_HERE
directory and double-click thePOSprint.py
file (the python executable).- You should see a GUI pop up, with a black box logging window behind it.
That's it! Before you try printing for the first time, I would recommend you make sure:
- The txt document & php document contain the data you want to print
- Note: the php file may contain formatting for printed text
Here are some common errors I've run into and how to solve (most of) them:
PHP Warning: (.../autoload.php): failed to open stream: No such file or directory in ...
- Make sure line 10 of POSprint.php is looking at the correct directory for escpos-php-development/autoload.php
- Error with function
readFile()
- readFile exists in some other libraries used in this repo, so can't make a new function named readFile
- Everything looks good, but printer is not printing (related to #2).
- If you don't see any comments from the batch file (like a line including
php POSprint.php
and"Batch file done"
), the batch file is probably not being called, meaning something in the python code probably went wrong.
- If you don't see any comments from the batch file (like a line including
PHP Warning: copy(\\DESKTOP-GFORQEO\<printer-name>): failed to open stream: No such file or directory in ...
- Hopefully you're naming and sharing your printer as
"SPRT POS Printer"
where I put"<printer-name>"
above. - This error is caused by the POS printer not being shared or if the shared printer name is spelled differently than that name of the printer that the
POSprint.php
file is trying to connect to (see theWindowsPrintConnector(<printer-name>)
function call).
- Hopefully you're naming and sharing your printer as
PHP Warning: PHP Startup: Unable to load dynamic library '<path-to...>\php_mbstring.dll - The specified module could not be found.
- Full error continues with:
PHP Fatal error: Uncaught Error: Call to undefined function Mike42\Escpos\PrintBuffers\mb_detect_encoding() in <path-to...>\escpos-php-development\src\Mike42\Escpos\PrintBuffers\EscposPrintBuffer.php:95
Stack trace: #0 <path-to...>\escpos-php-development\src\Mike42\Escpos\Printer.php(979): Mike42\Escpos\PrintBuffers\EscposPrintBuffer->writeText('StARS\n') #1 <path-to...>\POSprint.php(35): Mike42\Escpos\Printer->text('StARS\n') #2 {main} thrown in <path-to...>\escpos-php-development\src\Mike42\Escpos\PrintBuffers\EscposPrintBuffer.php on line 95
- This error occured when
extension_dir="..."
in thephp.ini
file had an incorrect directory set. Remember to set this to the location where the/ext
folder can be found - INCLUDE the/ext
at the end here!
- Full error continues with:
What is POSprint?
POSprint is a project that was built under very specific specifications. It may not be useful for others to see, but I hope it will bring a bit more light to the POS printing world.
The main flow of POSprint is:
- POSprint.py creates a GUI using Tkinter, and writes a number to the file POSprint_ClientIndexHolder.txt
- Once the "Print" button is clicked, python runs POSprint.bat
- POSprint.bat calls POSprint.php, as if it were from the Windows cmd
- POSprint.php calls some libraries built by Mike42 (Blog post link here) to send POS commands to the POS printer so some nice text is printed.
POSprint uses the following languages:
- Python 2.7
- Windows batch file commands
- PHP
- Code files
POSprint.bat
- Called by .py, triggers the .php file
POSprint.php
- Called by .bat file, connects to printer and reads data from .txt file(s)
POSprint.py
- Triggered by user, writes data to files and triggers .bat file
- Text files that will be produced in your directory:
POSprint_BigNumHolder.txt
- Created by
POSprint.py
- Holds the number to be printed in large text
- Created by
POSprint_ClientIndexHolder.txt
- Created by
POSprint.py
- Holds the index of the current client for in-order printing
- Created by
POSprint_LogHolder.txt
- Created by
POSprint.php
- Holds logged text (isn't printed, just logged)
- Created by
POSprint_ProgramHolder.txt
- Created by
POSprint.py
- Holds program text to be printed
- Created by
POSprint_SmallNumHolder.txt
- Created by
POSprint.py
- Holds the number to be printed in small text
- Created by