Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

         

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.




Back to Getting Started With Kapsel

7 Comments