Getting Started with Kapsel – Part 19 — Printer
Printer (New in SP06)
This plugin enables the ability to print using AirPrint on iOS and the Android Printing Framework on Android 4.4 or higher devices. It uses the open source Printer plugin.
For additional details on the Kapsel Printer plugin see the JavaScript file in a project that includes this plugin at
project_name\plugins\de.appplant.cordova.plugin.printer\www\printer.js
or the JS Documentation at Kapsel Printer API Reference.
The following steps will demonstrate using this plugin.
- Create the project.
cordova -d create C:\Kapsel_Projects\PrinterDemo com.mycompany.printer PrinterDemo "{\"plugin_search_path\":\"C:/SAP/MobileSDK3/KapselSDK/plugins/\"}" cd C:\Kapsel_Projects\PrinterDemo cordova -d platform add android cordova -d create ~/Documents/Kapsel_Projects/PrinterDemo com.mycompany.printer PrinterDemo "{\"plugin_search_path\":\"/Users/i826567/SAP/MobileSDK3/KapselSDK/plugins/\"}" cd ~/Documents/Kapsel_Projects/PrinterDemo cordova -d platform add ios
- Add the Kapsel or open source printer plugin.
cordova -d plugin add de.appplant.cordova.plugin.printer or cordova -d plugin add https://github.com/katzer/cordova-plugin-printer.git
- Replace www\index.html with the contents of index.html.
- Copy the files to the platform directory by running
cordova -d prepare
- Use the Android IDE or Xcode to deploy and run the project.
The Print Original Page passes the location.href to the print method while Print Current Page passes document.body which includes the logged messages such as Printer is available. Notice that thedate text input is empty either way. Finally the Print Other Page prints the current weather forecast in Waterloo Ontario (http://weather.gc.ca/city/pages/on-82_metric_e.html).
The following demonstrates how to view the results of printing a page on an Andoid emulator and an iOS simulator. Press the Is Printer Available button and then the Print Current Page.
To download the Printer Simulator, in Xcode, choose Xcode > More Developer Tools… > Hardware IO TOols for Xcode – Xcode 6.1.
Once downloaded start the Printer Simulator. Note if an error appears in Xcode while attempting to print, the following may help. AirPrint Connection Refused Error.
Hi Daniel,
Very nice document.
Is there any API available which will print reports from windows 8.1 platforms to bluetooth printers?
We are developing SAPUI5 application which will be packaged in Cordova container, i searched KAPSEL/Cordova, but no API to print for Windows 8.1 platforms.
Can you please help me in this regard.
Regards
Saket
I don't believe Kapsel/SMP SDK provides this in the SP08 release.
http://help.sap.com/saphelp_smp308sdk/helpdata/en/10/e4e12b7a7d4de3a2b80c9c935aded2/content.htm
I suppose you could look for an open source plugin to provide this. I have not myself used one on Windows.
Regards,
Dan van Leeuwen
Hi Daniel,
I'm trying to print the some data from my Cordova app to a bluetooth printer imZ320 but I get an error.
I've tried to do some debug on the issue and I found that the exception message is:
Now let me tell you what I've installed (nothing modified just open source code). 1. Printer app -http://scn.sap.com/docs/DOC-61345 2. Cordova Kapsel plugin - https://github.com/katzer/cordova-plugin-printer/tree/network-printer (I know it said "deprecated" but I need to make something work on my device). By default the plugin from the SCN message send the "object" to the Android print server and creates a PDF file. In my case I need o send it to a real printer, ergo imZ320 and the network-printer.
The intent is created in the function below (found in the print.java file of the plugin):
Other sources that I found that work (but native apps created): https://km.zebra.com/kb/index?page=content&id=WH62 and https://opendatakit.org/downloads/download-category/sensors-and-printers/
I tried to reverse engineer them but with no luck 🙁
And here is a related plugin that I found on github to zebra printing, but couldn't make it do anything:https://github.com/mchapper/cordova-plugin-zebra-printer/
Regards,
Marius
Any new about the support of this plugin in Windows 8.1?
Thank you!
There is a table at the link below that mentions Windows 8.1.
http://help.sap.com/saphelp_smp3011sdk/helpdata/en/98/c5d867767f4db387983c49dd5cca23/content.htm?frameset=/en/ed/65d7f0acbd4ae2bb4bb59e0aa389ad/frameset.htm¤t_toc=/en/7c/01cda6700610149b10c2f2a86d335b/plain.htm&node_id=618&show_children=false
Updating the content displayed in this section is on my todo list 🙂
Note, the version that I will be updating is.
Getting Started with Kapsel - Part 14 -- Printer (SP09+)
Regards,
Dan van Leeuwen
Hi Daniel
When i click on the index.html file as you said i am getting page not found . Kindly send me the link where i can the index.html code
Regards
Ashwin
This blog post was archived and covers an early version of the Kapsel SDK. Please see https://blogs.sap.com/2015/07/20/getting-started-with-kapsel-part-14-printer-sp09/ or for the very latest version of the blog series see https://blogs.sap.com/2016/10/20/getting-started-kapsel-part-1-sp13/
Regards,
Dan van Leeuwen