Skip to content

Beamanator/POS-Print-Files

Repository files navigation

POSprint

How to use POSprint

Follow these steps in order to get POSprint set up properly:

  1. Download the entire project directory from the POS-Print-Files repo.
  2. 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)
  3. 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
  4. 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
  5. 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')
  6. 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.
  7. Important Step: Copy all of the files starting with POSprint into the folder called CODE_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.

Now you're ready to go? This is how you should run the program:

  1. Navigate into your /CODE_GOES_HERE directory and double-click the POSprint.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:

  1. The txt document & php document contain the data you want to print
    • Note: the php file may contain formatting for printed text

Possible Issues / Errors

Here are some common errors I've run into and how to solve (most of) them:

  1. 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
  2. Error with function readFile()
    • readFile exists in some other libraries used in this repo, so can't make a new function named readFile
  3. 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.
  4. 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 the WindowsPrintConnector(<printer-name>) function call).
  5. 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 the php.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!

About

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

Explanation of Files:

  1. Code files
    1. POSprint.bat
      • Called by .py, triggers the .php file
    2. POSprint.php
      • Called by .bat file, connects to printer and reads data from .txt file(s)
    3. POSprint.py
      • Triggered by user, writes data to files and triggers .bat file
  2. Text files that will be produced in your directory:
    1. POSprint_BigNumHolder.txt
      • Created by POSprint.py
      • Holds the number to be printed in large text
    2. POSprint_ClientIndexHolder.txt
      • Created by POSprint.py
      • Holds the index of the current client for in-order printing
    3. POSprint_LogHolder.txt
      • Created by POSprint.php
      • Holds logged text (isn't printed, just logged)
    4. POSprint_ProgramHolder.txt
      • Created by POSprint.py
      • Holds program text to be printed
    5. POSprint_SmallNumHolder.txt
      • Created by POSprint.py
      • Holds the number to be printed in small text

About

Receipt Printer Software

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published