Paper cutting (trigger guillotine) on Bematech MP-4200 TH printer

Asked

Viewed 1,645 times

1

How to make the Bematech MP-4200 TH (non-fiscal) printer cut paper at the end of printing in a Java application?

1 answer

5

Documenting the solution I found.

Caveats: 1.: Avoid mixing printing via DLL with via Spooler, can cause communication failures and generate spurious characters in printing. 2.: the DLL (or my installation) has a bug, the Formatatx command does not accept font 3 (Elite), ignore and print with letter 2 (normal) or 1 (condensed).

  • For the printer of the model in question, which is a non-tax, the way to interact with Java according to Bematech is via JNA. (Obs.: is not the only, but it is the one that worked). There is an example that uses JNI and the package Bematech.jar, but it’s for tax printers, so it doesn’t work on MP-4200 TH. There are reports of the printer working in Java accepting ESC/POS commands if installed with Generic Driver, but with me it didn’t work, so I gave up this approach.
  • This answer is for Windows 7 64 bit, but the JDK may be 64 or 32 bit, you will only have to use the correct DLL for your case (mp2032 or mp2064).
  • If using the 32-bit version, the files mp2032.dll, mp2032.ini, Siusbxp.dll contained in the mp2032 package must be copied to the root folder of the Java application (returned by System.out.println(System.getProperty("user.dir"))). It should also work if you copy to C: Windows System32, but I didn’t take the test.
  • If using 64-bit version, the files mp2064.dll, mp2064.ini, Siusbxp.dll contained in the mp2064 package must be copied to the same location as above.
  • If you want to know more about the archives .ini, see this article.
  • Download the Example JNA from Bematech and import into Eclipse (or the IDE of your choice).
  • If you are using the 64-bit version, change the part of the code that says "mp2032" to "mp2064". Or to make the code support both versions add the following to the interface BematechNFiscal.java:

    public static final boolean IS_64_BIT_JVM =
        "64".equals(System.getProperty("sun.arch.data.model"));
    public static final BematechNFiscal INSTANCE =
        (BematechNFiscal) Native.loadLibrary(IS_64_BIT_JVM ?
        "mp2064" : "mp2032", BematechNFiscal.class);
    

Add to interface BematechNFiscal.java the following line:

public int AcionaGuilhotina(int tipoDeCorte);

You can now edit the class Principal.java and call the AcionaGuilhotina(1) for total cutting or AcionaGuilhotina(0) for partial cutting.

This is the orientation to use a printer previously installed on the machine. To install the printer you need to install the driver that comes along with the mp2032 or mp2064 package and also with installation instructions (a PDF file). Follow these instructions to install the driver (current version 3.4.0.0). Note that between uninstallations and installations you have to restart the machine.

For the printer to be added to the printer list of the operating system, you need to install the Spooler Driver. It comes bundled with printer drivers under the name Bematech MP4200 TH - Driver Win Bemasetup MP4K x64 V4.2.0.exe.

This last driver I will leave to your charge to find and download, it comes in a package of other 4 or 5 drivers including for Linux. I hope some good soul will come here and complete the information by providing the link.

Tip: This is the Bematech download site.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.