0

We have a POS written in PHP which needs to interact with a POS printer. The printer support JavaPOS. The state of PHP POS is that it generates a bill and waits for a user to select a printer.

The issue now is, the JavaPOS printer doesn't show up. I am able to interact with using test Java code which has the necessary drivers & jpos.xml. I wish to 'install' this.

From my understanding for past four days going through JavaPOS manuals from different manufactures [EPSON, Starmicronics, Diebold Nixdorfag ], it is not possible. JavaPOS is meant for POS system written in Java [JavaFX to Spring].

But I find it very odd to believe this. I believe this shouldn't be the case because if this true, it would make very hard for POS not written in Java or .Net to interact with plethora of POS devices and terminal out there.

Hence, is it possible to interact with non Java & non .Net POS to send print command to JavaPOS device?

Please note, simply installing the device and sending a print command doesn't fix the issue. Say, if I want to add a logo to the receipt along with dynamic data in the footer of the receipt, Java code will be required for .Net to make it 'rich'. Now, where does this Java code specifically sit? Is it some virtual device which runs in the background and pretends to be a printer and shows up in the print dialog in a, say PHP POS?

Sample Java code written to interact with JavaPOS with jpos.xml file as reference.

public static void main(String[] args) {
    File f = new File(PrintFTest.class.getClassLoader().getResource("jpos.xml").getPath());

    System.setProperty(JposPropertiesConst.JPOS_POPULATOR_FILE_PROP_NAME, f.getAbsolutePath());
    //System.getProperties().list(System.out);
    FiscalPrinter fiscalPrinter = new FiscalPrinter();

    // Get Access to it
    try {
        fiscalPrinter.open("printf");
        fiscalPrinter.claim(1000);
        fiscalPrinter.setDeviceEnabled(true);
    } catch (JposException e) {
        System.out.println("Exception at Access");
        e.printStackTrace();
    }

    // Print 
    try {
        fiscalPrinter.resetPrinter();
        fiscalPrinter.beginFiscalReceipt(true);
        fiscalPrinter.printRecItem("Salame", 40000, 0, 0, 0, "");
        fiscalPrinter.printRecTotal(40000, 40000, "CONTANTI");
        fiscalPrinter.endFiscalReceipt(false);
    } catch (JposException e) {
        System.out.println("Exception at Print");
    }

    try {
        System.out.println("1FP - Fiscal Printer disabling");
        fiscalPrinter.setDeviceEnabled(false);
        System.out.println("2FP - Fiscal Printer releasing");
        fiscalPrinter.release();
        System.out.println("2FP - Fiscal Printer closing");
        fiscalPrinter.close();
    } catch (JposException e) {
        System.out.println("Exception at Close");
    }

}

}

Andrés Alcarraz
  • 1,570
  • 1
  • 12
  • 21
devyJava
  • 135
  • 8

1 Answers1

1

It should contain the installation/setup/configuration method in the JavaPOS provided by each printer vendor and its user's manual.

Please install and configure equipment and software accordingly.

However, in general, JavaPOS printers are rarely recognized as standard printer devices for their respective operating systems.

For example, there is such an article.
Getting started with Java POS development
JavaPOS Working Group

Next, it is recommended that you use these programs to operate and verify the printer only in the Java environment.
emigonza/POStest
ntsggr/JavaPOS-POStest-2

There are several ways to use Java from PHP as follows.
PHP/Java Integration
Using PHP-Java Bridges with WebLogic Server
What is the PHP/Java Bridge?
How it works
Java Bridge
How to call custom java methods from PHP?

There is no problem if it can be solved by the above method, but I recommend the following method.

  • Combine the Java program and JavaPOS to create a program that runs standalone.
  • The program provides functions similar to POS processing units such as "receipt printing".
  • This program communicates with PHP's POS in a simple and light way such as a bare TCP/IP socket, so that request issuance, completion notification or completion confirmation can be performed asynchronously.

In Addition:

The following is an example of a POS application that is entirely made in Java.
Since these are open source, it seems to be a reference for programming.
However, it is unknown whether JavaPOS control is used or not.

Openbravo Java POS
Floreant POS

The following is an example of an open source POS application written in PHP.
Probably JavaPOS will not be used.

OpenSourcePOS
WallacePOS

kunif
  • 4,060
  • 2
  • 10
  • 30
  • The vendor did provide with jpos.xml & Java class to test if it works. It runs without any need to **install** the printer. I went through all the links and were very helpful. What I **really* want to achieve is your first bullet point, "Java Program and JavaPOS" to run standalone. In the POS, when _generate receipt_ is clicked, it shows the typical print dialog asking us to select an existing printer. How do I work with this? Do I create a virtual Java printer which takes a PDF from POS and parses it, and prints line by line in Java? – devyJava Jan 09 '19 at 05:10
  • @devyJava, Normally, when you create a receipt image with text before creating a PDF, you make a print request to the JavaPOS printer program. Since only one POS printer is usually connected, it is unnecessary to select a printer. – kunif Jan 09 '19 at 05:52
  • When the button is clicked to print receipt, it is the same behavior seen in Microsoft Word after pressing `Ctrl+P`. The part I have doubt is the when a print request is made in the POS [written in PHP], how do I invoke the JavaPOS compatible printer? Like you said, there is no really a _installation_ of POS device seen with regular household _HP Injket_ printer nor the vendor as any available on the site. All I have are the regular TestPrint.java, jpos.xml and couple of other JAR libs to make it run. Do you believe a PHP -> Java bridge is necessary? – devyJava Jan 09 '19 at 10:42
  • I've been going through manuals and even in your links, I haven't came across any guideline to make the JavaPOS become a independent, standalone 'printer' which runs in the background of the host machine. Now if a print dialog is opened, the JavaPOS device will show up. Or am I missing something crucial in the picture? Using POS made in Java is out of the question, its written in PHP. – devyJava Jan 09 '19 at 10:46
  • This is because I thought that the mechanism recommended by PHP POS application is not good as the combination of Java and JavaPOS becomes complicated. Regardless of the method, it is thought that the mechanism of using the JavaPOS device from the PHP POS application has not been announced or become open source. So, regarding this, you need to develop from the beginning as you become a pioneer. – kunif Jan 09 '19 at 11:02
  • I'm sorry but I didn't quiet follow you. I'm still going through PDFs from other vendors and there is one thing I don't understand. If the printer is to connected remotely via an IP address [not USB], do we still require driver to operate with the printer? The device follows UPOS specification. – devyJava Jan 09 '19 at 12:30
  • I just downloaded ProBase POS 2.6 from [here](https://www.dieboldnixdorfag.com/de-de/customer-service/documentation-services/pos-kiosk-systems-peripherals/software-downloads/probase-pos/probase-pos-download) I read the manual and it proclaims the middleware to be general for all UPOS. This should mean a non mainstream vendor thermal printer or fiscal printer should work under it as long as it support UPOS specification. Is my understanding correct? – devyJava Jan 09 '19 at 12:32
  • For a network printer, it depends on the method you are going to use. If you use it as a JavaPOS printer, you do not need a device driver, but JavaPOS Control (! =Device driver) is necessary. If you use it as a simple ESC/POS printer, it is considered OK if you can communicate with TCP/IP socket. – kunif Jan 09 '19 at 12:46
  • Diebold Nixdorf is a powerful member of UnifiedPOS. ProBasePOS supports JavaPOS devices. However, what they support is centered on their device. Connecting devices other than Nixdorf is possible, but it is considered difficult. – kunif Jan 09 '19 at 12:55
  • Alright. So it seems to invoke any action on a JavaPOS compatible device [supports LAN] e.g. thermal printer, fiscal printer, it is possible to do without a device manager. It is OK to do with TCP/IP socket WITHOUT any device driver. Going back to our POS which is in in PHP, jpos.xml & javaPOS compatibility is useless. The only way to make it work from the POS without having the device listed in printing is to 1) build a bridge between PHP & Java. [I don't even know what kind of input will the PHP will send to the Java _back end_, one single blob pdf, stream of strings, or something else... – devyJava Jan 09 '19 at 13:27
  • Or to completely ignore the jpos.xml and anything related with Java and have this integrated into the POS application https://github.com/mike42/escpos-php I don't know how PHP works [I do Java] but the command to _generate bill_ is invoked which leads to a print dialog being shown, it should load up `escpos-php` instead... – devyJava Jan 09 '19 at 13:29
  • I looked into the link you just posted, https://github.com/opensourcepos/opensourcepos/wiki/Printing#fiscal-printing seem to be related to what I am facing. The device is a fiscal printer, supports/follows UPOS standard. There is no device driver but it does come with jpos.xml and required Java libs to make it work programmatically in Java. I will conclude that a bridge between PHP and Java is required. The whole concept of setting up a virtual printer which shows up in the print dialog sounds is something I have no technical knowledge in. – devyJava Jan 09 '19 at 13:41
  • The last part, I do not have knowledge, so I can not discuss it here. Please you should issue a new question. – kunif Jan 09 '19 at 14:03
  • I will. Thank you for the help. Now I know without a doubt there is no straight forward way to make a 'driver' style using jpos.xml in Java for any POS. JavaPOS is meant for Java. Only. Thanks :) … there seems to be webPOS which works with JavaPOS/UPOS written in "WSPOS1_1_Technical_Specification_2011_June_15.pdf" which works with UPOS specification over the web. – devyJava Jan 09 '19 at 15:15
  • @devyJava, The latest WS-POS is version 1.3, and the specification is here. [UnifiedPOS](https://www.omg.org/retail/unified-pos.htm) – kunif Jan 09 '19 at 15:24