From 6436b92526a4b607eec97436427e52ef8b616549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Katzer?= Date: Sat, 10 Aug 2013 12:44:28 +0200 Subject: [PATCH] Update README.md --- README.md | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 71 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fbc9e15..18fe81b 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,76 @@ Cordova Printer-Plugin ====================== -by Sebastián Katzer ([github.com/katzer](https://github.com/katzer)) A bunch of printing plugins for Cordova 3.x.x -## Platforms -- iOS *(Print from iOS devices to AirPrint compatible printers)* +by Sebastián Katzer ([github.com/katzer](https://github.com/katzer)) + +## Supported Platforms +- **iOS** *(Print from iOS devices to AirPrint compatible printers)* + +## Adding the Plugin to your project +Through the [Command-line Interface](http://cordova.apache.org/docs/en/3.0.0/guide_cli_index.md.html#The%20Command-line%20Interface): + +```bash +cordova plugin add https://github.com/katzer/cordova-plugin-printer.git +``` + +## Release Notes +#### Version 0.0.1 (10.08.2013) +- Added iOS support + +## Using the plugin +The plugin creates the object ```window.plugin.printer``` with two methods: + +### isServiceAvailable() ### +Printing is only available on devices capable of multi-tasking (iPhone 3GS, iPhone 4 etc.) running iOS 4.2 or later. You can use this function to hide print functionality from users who will be unable to use it. Function takes a callback function, passed to which is a boolean property. + +```javascript +/* + * Find out if printing is available. Use this for showing/hiding print buttons. + */ +window.plugin.printer.isServiceAvailable( + function (isAvailable) { + alert(isavailable ? 'Service is available' : 'Service NOT available'); + } +); +``` + +### print() ### +Function takes an html string and (optionally) a success callback and a failure callback. + +```javascript +// Get HTML string +var page = document.body.innerHTML; + +/* + * Pass an HTML and - optionally - success function, error function. + */ +window.plugin.printer.print(page); +``` + +#### Testing in the iOS Simulator #### +There's no need to waste lots of paper when testing - if you're using the iOS simulator, select File->Open Printer Simulator to open some dummy printers (print outs will appear as PDF files). + +#### Adding Page Breaks to Printouts #### +Use the 'page-break-before' property to specify a page break, e.g. + +```html +

+First page. +

+ +

+Second page. +

+``` + +See W3Schools for more more information: http://www.w3schools.com/cssref/pr_print_pagebb.asp + +Note: you will need to add an extra top margin to new pages. + + +#### Printing on Real Printers #### +Printing is only supported on AirPrint-enabled printers or with the use of third-party software on your computer. The following pages contain more information: + - AirPrint-enabled printers: http://www.apple.com/ipad/features/airprint.html + - Enabling AirPrint on your computer: http://reviews.cnet.com/8301-19512_7-20023976-233.html, or http://www.ecamm.com/mac/printopia/