Giter VIP home page Giter VIP logo

cordova-print-pdf-plugin's Introduction

Print PDF plugin for Cordova / PhoneGap

This plugin brings up a native overlay to print a PDF document using AirPrint for iOS and Android Printing APIs on Android devices running 4.4 or later. If you need to support printing on an Android device running 4.3 or less, checkout the google-cloud-print branch.

Usage

print(options)

Use the print function to print an encoded document via a native printing interface.

window.plugins.PrintPDF.print(options);

The default options object

var options = {

	data: null, 	// print data, base64 string (required)

	title: '', 		// title of document

	dialogX: -1,	// if a dialog coord is not set, it defaults to -1.
					// the iOS method will fall back to center if it gets
	dialogY: -1,	// a dialog coord less than 0. (iPad only)

	success: null,	// success callback function, argument is a json string.
	 				// parsed json format:
					// {success: true}

	error: null		// error callback function, argument is a json string.
	 				// parsed json format:
					// {success: [boolean], available: [boolean], error: [string], dismissed: [boolean]}
	
};

Example:

var encodedString = 'base64encodedStringHere';
window.plugins.PrintPDF.print({
	data: encodedString,
	title: 'Print Document',
	success: function(){
		console.log('success');
	},
	error: function(data){
		data = JSON.parse(data);
		console.log('failed: ' + data.error);
	}
});

dismiss()

Use the dismiss function to programmatically dismiss the print dialog (iOS only). There are no options that can be passed in. When the dialog is dismissed it will trigger the error callback that was set for the print() function with the dismissed parameter set to true.

window.plugins.PrintPDF.dismiss();

isPrintingAvailable(callback)

Use the isPrintingAvailable function to check if native printing is supported and available.

window.plugins.PrintPDF.isPrintingAvailable(callback);

Example:

window.plugins.PrintPDF.isPrintingAvailable( function(isAvailable) {
	console.log('printing is available: '+ isAvailable);
});

cordova-print-pdf-plugin's People

Contributors

sarahgoldman avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.