All Projects → katzer → Cordova Plugin Printer

katzer / Cordova Plugin Printer

Licence: apache-2.0
Print HTML documents

Projects that are alternatives of or similar to Cordova Plugin Printer

cordova-plugin-foxitpdf
Cordova plugin for Foxit PDF SDK to View PDF Files
Stars: ✭ 19 (-92.83%)
Mutual labels:  cordova-plugin
skwas-cordova-plugin-datetimepicker
Cordova Plugin for showing a native date, time or datetime picker.
Stars: ✭ 37 (-86.04%)
Mutual labels:  cordova-plugin
objprint
A library that can print Python objects in human readable format
Stars: ✭ 141 (-46.79%)
Mutual labels:  print
mkdocs-print-site-plugin
MkDocs Plugin that adds an additional page that combines all pages, allowing easy exports to PDF and standalone HTML.
Stars: ✭ 38 (-85.66%)
Mutual labels:  print
react-native-star-prnt
React-Native bridge to communicate with Star Micronics Bluetooth/LAN Printers
Stars: ✭ 61 (-76.98%)
Mutual labels:  print
ionic-native-sms-retriever-plugin-master
Cross-platform plugin for Cordova / PhoneGap to Retrieve SMS. Available for Android.
Stars: ✭ 16 (-93.96%)
Mutual labels:  cordova-plugin
cordova-plugin-flurryanalytics
Adds support for all that Flurry Analytics flavored goodness to your Cordova based apps
Stars: ✭ 23 (-91.32%)
Mutual labels:  cordova-plugin
JimuReport
「低代码可视化报表」类似excel操作风格,在线拖拽完成设计!功能涵盖: 报表设计、图形报表、打印设计、大屏设计等,完全免费!秉承“简单、易用、专业”的产品理念,极大的降低报表开发难度、缩短开发周期、解决各类报表难题。
Stars: ✭ 2,895 (+992.45%)
Mutual labels:  print
printer
A fancy logger yet lightweight, and configurable. 🖨
Stars: ✭ 65 (-75.47%)
Mutual labels:  print
gscloudplugin
浏览器打印PDF。 浏览器打印HTML。 浏览器打印图片。 浏览器打印Word。浏览器打印Excel。浏览器打印PPT。浏览器打印自定义绘图。浏览器打印微软报表。 使用静默方式打印。蓝牙打印。读写串口数据。读取电子秤重量
Stars: ✭ 18 (-93.21%)
Mutual labels:  print
pydbg
Python implementation of the Rust `dbg` macro
Stars: ✭ 85 (-67.92%)
Mutual labels:  print
senaite.impress
HTML to PDF Rendering Engine for SENAITE
Stars: ✭ 16 (-93.96%)
Mutual labels:  print
cordova-plugin-smartconfig
A cordova plugin for Smart Configure ESP8266 & ESP32 with Espressif Esptouch protocol.
Stars: ✭ 17 (-93.58%)
Mutual labels:  cordova-plugin
cordova-plugin-tesseract
Cordova Plugin for OCR process using Tesseract
Stars: ✭ 70 (-73.58%)
Mutual labels:  cordova-plugin
ionic-signature-pad
Ionic plugin to input singnature pad
Stars: ✭ 15 (-94.34%)
Mutual labels:  cordova-plugin
cordova-plugin-apkupdater
This plugin allows your Android app to download and install compressed updates without the Google Play Store.
Stars: ✭ 46 (-82.64%)
Mutual labels:  cordova-plugin
cordova-plugin-today-widget
Add a today widget app extension target to your cordova project.
Stars: ✭ 51 (-80.75%)
Mutual labels:  cordova-plugin
Cordova Plugin Geofence
Geofencing plugin for cordova
Stars: ✭ 261 (-1.51%)
Mutual labels:  cordova-plugin
bonaparticle
The LaTeX magazine class that doesn’t get in your way.
Stars: ✭ 20 (-92.45%)
Mutual labels:  print
scanbot-sdk-example-ionic
Scanbot scanner SDK example app for Ionic with Cordova.
Stars: ✭ 24 (-90.94%)
Mutual labels:  cordova-plugin

SAMPLE APP 👉

Cordova Print Plugin
npm version License PayPayl donate button

Plugin for Cordova to print documents, photos, HTML and plain text from iOS, Android and Windows Universal apps.

cordova.plugins.printer.print('<b>Hello Cordova!</b>');

Supported Printer Interfaces

  • Apple AirPrint
  • Android Print
  • Windows Print

Supported Content

  • HTML
  • Text
  • Base64
  • Images
  • PDF

Supported Platforms

  • Android 4.4+
  • iOS 10+
  • Windows 10 UWP
  • Browser

Basics

The plugin creates the object cordova.plugins.printer and is accessible after the deviceready event has been fired.

document.addEventListener('deviceready', function () {
    // cordova.plugins.printer is now available
}, false);

Prints the contents of the web view:

cordova.plugins.printer.print();

Plain text:

cordova.plugins.printer.print("Hello\nWorld!");

HTML & CSS:

cordova.plugins.printer.print('<h1>Hello World!</h1>');

Images, PDF and other documents:

cordova.plugins.printer.print('file://img/logo.png');

Base64 encoded content:

cordova.plugins.printer.print('base64://...');

Note: On the browser platform the plugin only supports to print the contents of the web view.

Formatting

It's possible to pass format options to the print method that overrides the defaults:

cordova.plugins.printer.print(content, options, callback);

The defaults are defined as follows:

cordova.plugins.printer.setDefaults({ monochrome: true });

The list of possible options depend on the platform, the content type and the capabilities of the printer.

Name Description Type Platform
name The name of the print job and of the document. String all
copies The number of copies for the print task. Number iOS
Windows
pageCount Limits the pages to print even the document contains more.
To skip the last n pages you can assign a negative value on iOS.
Number iOS
Android
duplex Either double-sided on short site (duplex:'short'), double-sided on long site (duplex:'long') or single-sided (duplex:'none'). String all
orientation The orientation of the printed content, portrait or landscape. String all
monochrome If your application only prints black text, setting this property to true can result in better performance in many cases. Boolean all
photo Set to true to change the media type to photography for higher quality. Boolean iOS
Windows
autoFit Set to false to disable downscaling the image to fit into the content aread. Boolean Android
printer The network URL to the printer. String iOS
maxHeight
maxWidth
Defines the maximum size of the content area. Unit iOS
margin Set to false to avoid margins. Boolean all
margin.top
margin.left
margin.right
margin.bottom
The margins for each printed page. Each printer might have its own minimum margins depends on media type and paper format. Unit iOS
ui.hideNumberOfCopies Set to true to hide the control for the number of copies. Boolean iOS
ui.hidePaperFormat Set to true to hide the control for the paper format. Boolean iOS
ui.top
ui.left
The position of the printer picker. Number iPad
ui.height
ui.width
The size of the printer picker. Number iPad
paper.width
paper.height
The dimensions of the paper – iOS will will try to choose a format which fits bests. Unit iOS
paper.name The name of the format like IsoA4 or Roll22Inch.
https://docs.microsoft.com/en-us/uwp/api/windows.graphics.printing.printmediasize
String Windows
paper.length On roll-fed printers you can decide when the printer cuts the paper. Unit iOS
font.name The name of the font family String iOS
font.size The size of the font Number iOS
Android
font.italic
font.bold
Set to true to enable these font traits. Boolean iOS
font.align Possible alignments are left, right, center and justified. String iOS
font.color The color of the font in hexa-decimal RGB format - "FF0000" means red. String iOS
header.height
footer.height
The height of the header or footer on each page. Unit iOS
header.labels
footer.labels
An array of labels to display. Only use if there are more then one. Array iOS
header.label.text
footer.label.text
The plain text to display. Use %ld to indicate where to insert the page index.
For example "Page %ld" would result into "Page 1", "Page 2", ...
String iOS
header.label.top
header.label.right
header.label.left
header.label.bottom
footer.label.*
The relative position where to place the label within the footer or header area. Unit iOS
header.label.font
footer.label.font
The font attributes for the label. Object iOS
header.label.showPageIndex
footer.label.showPageIndex
Set to true if you want to display the page index.
Boolean iOS

The Unit type can be either a (float) number or a string with a special suffix.

  • Supported unit suffixes are in for inches, mm for millimeters, cm for centimeters and pt for points
  • "2in" are two inches whereas 2.0 or "2.0pt" are identical for two points
  • One inch are 72.0 points

Direct Print

For iOS its possible to send the content directly to the printer without any dialog. Todo so pass the network URL as an option:

cordova.plugins.printer.print(content, { printer: 'ipp://...' });

To let the user pick an available printer:

cordova.plugins.printer.pick(function (url) {});

It's possible to specify the position of the picker:

cordova.plugins.printer.pick({ top: 40, left: 30 }, callback);

Note: By passing an invalid URL, the application will throw an Unable to connect to (null) exception and possibly crash.

Printable Document Types

The list of supported document types differ between mobile platforms. As of writing, Windows UWP only supports HTML and plain text.

To get a list of all printable document types:

cordova.plugins.printer.getPrintableTypes(callback);

To check if printing is supported in general:

cordova.plugins.printer.canPrintItem(callback);

Or in particular:

cordova.plugins.printer.canPrintItem('file://css/index.css', callback);

Sample

var options = {
    font: {
        size: 22,
        italic: true,
        align: 'center'
    },
    header: {
        height: '6cm',
        label: {
            text: "\n\nDie Freuden",
            font: {
                bold: true,
                size: 37,
                align: 'center'
            }
        }
    },
    footer: {
        height: '4cm',
        label: {
            text: 'Johann Wolfgang von Goethe, 1749-1832, deutscher Dichter, Naturforscher',
            font: { align: 'center' }
        }
    }
};

cordova.plugins.printer.print("Es flattert um die Quelle\nDie wechselnde Libelle,...", options);

The result will look like this for iOS:

ttt

Installation

Execute from the projects root folder:

$ cordova plugin add cordova-plugin-printer

Or install a specific version:

$ cordova plugin add [email protected]

Or install the latest head version:

$ cordova plugin add https://github.com/katzer/cordova-plugin-printer.git

Or install from local source:

$ cordova plugin add <path> --nofetch --nosave

Then execute:

cordova build

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

This software is released under the Apache 2.0 License.

Made with 😋 from Leipzig

© 2013 appPlant GmbH

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].