0

I just got this android device that has a thermal printer. It also comes with a SDK that has an external .jar file that can be used to communicate with the device.

Now I am trying to print text from javascript to the device. In the samples they have given for java projects you can print using the following:

import com.nbbse.printer.Printer;
public static Printer print;
print = Printer.getInstance();
print.printText(“Printer testing!!!”);
print.printText(“Printer testing!!!”, 3);
print.printText(“Printer testing!!!”, true);
print.printText("Printer Testing!!!", 2, false);

How can I achieve the same in a cordova application? I have started by adding the .jar in the libs folder and then including this line in the config.xml:

<lib-file src="platforms/android/libs/MP3_Api_V0.6.jar"/>

How can I invoke the printing directly from a javascript?

1 Answers1

0

You have to create a cordova-plugin to actually use the native library. You can find the plugin development guide here.

You will have to move your <lib-file> tag from config.xml to the plugin.xml of your plugin. I also think you did put the .jar directly into the android platform folder. You should never directly modify this folder as it is recreated/modified on build. You can put the .jar file in a subfolder of your plugin and reference it like that in plugin.xml (if you name the subfolder libs):

<lib-file src="libs/MP3_Api_V0.6.jar"/>

The docs for this are here.

David
  • 7,387
  • 3
  • 22
  • 39