{"id":24755231,"url":"https://github.com/katzer/cordova-plugin-printer","last_synced_at":"2025-05-15T21:04:19.674Z","repository":{"id":9978431,"uuid":"12005791","full_name":"katzer/cordova-plugin-printer","owner":"katzer","description":"Print HTML documents","archived":false,"fork":false,"pushed_at":"2024-02-13T15:20:27.000Z","size":28997,"stargazers_count":315,"open_issues_count":90,"forks_count":297,"subscribers_count":42,"default_branch":"master","last_synced_at":"2025-05-05T07:04:42.893Z","etag":null,"topics":["cordova-android-plugin","cordova-browser-plugin","cordova-ios-plugin","cordova-plugin","cordova-plugin-printer","cordova-windows-plugin","print"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/katzer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-08-09T16:44:19.000Z","updated_at":"2025-05-04T08:23:41.000Z","dependencies_parsed_at":"2024-06-18T16:56:43.049Z","dependency_job_id":null,"html_url":"https://github.com/katzer/cordova-plugin-printer","commit_stats":{"total_commits":235,"total_committers":16,"mean_commits":14.6875,"dds":0.09361702127659577,"last_synced_commit":"672d8045181fe0eb4772c479681bd6f479ca8949"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katzer%2Fcordova-plugin-printer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katzer%2Fcordova-plugin-printer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katzer%2Fcordova-plugin-printer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katzer%2Fcordova-plugin-printer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/katzer","download_url":"https://codeload.github.com/katzer/cordova-plugin-printer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254422754,"owners_count":22068678,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cordova-android-plugin","cordova-browser-plugin","cordova-ios-plugin","cordova-plugin","cordova-plugin-printer","cordova-windows-plugin","print"],"created_at":"2025-01-28T12:37:41.474Z","updated_at":"2025-05-15T21:04:19.648Z","avatar_url":"https://github.com/katzer.png","language":"Objective-C","funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=L3HKQCD9UA35A"],"categories":[],"sub_categories":[],"readme":"\n\u003cp align=\"left\"\u003e\n    \u003cb\u003e\u003ca href=\"https://github.com/katzer/cordova-plugin-printer/blob/example/README.md\"\u003eSAMPLE APP\u003c/a\u003e :point_right:\u003c/b\u003e\n\u003c/p\u003e\n\n# Cordova Print Plugin \u003cbr\u003e [![npm version](https://badge.fury.io/js/cordova-plugin-printer.svg)](http://badge.fury.io/js/cordova-plugin-printer) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![PayPayl donate button](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=L3HKQCD9UA35A \"Donate once-off to this project using Paypal\")\n\nPlugin for [Cordova][cordova] to print documents, photos, HTML and plain text from iOS, Android and Windows Universal apps.\n\n```js\ncordova.plugins.printer.print('\u003cb\u003eHello Cordova!\u003c/b\u003e');\n```\n\n\u003cimg width=\"280px\" align=\"right\" src=\"https://github.com/katzer/cordova-plugin-printer/blob/example/images/print.png\"\u003e\n\n### Supported Printer Interfaces\n\n- Apple AirPrint\n- Android Print\n- Windows Print\n\n### Supported Content\n\n- HTML\n- Text\n- Base64\n- Images\n- PDF\n\n### Supported Platforms\n\n- Android 4.4+\n- iOS 10+\n- Windows 10 UWP\n- Browser\n\n## Basics\n\nThe plugin creates the object `cordova.plugins.printer` and is accessible after the *deviceready* event has been fired.\n\n```js\ndocument.addEventListener('deviceready', function () {\n    // cordova.plugins.printer is now available\n}, false);\n```\n\nPrints the contents of the web view:\n\n```javascript\ncordova.plugins.printer.print();\n```\n\nPlain text:\n\n```javascript\ncordova.plugins.printer.print(\"Hello\\nWorld!\");\n```\n\nHTML \u0026 CSS:\n\n```javascript\ncordova.plugins.printer.print('\u003ch1\u003eHello World!\u003c/h1\u003e');\n```\n\nImages, PDF and other documents:\n\n```javascript\ncordova.plugins.printer.print('file://img/logo.png');\n```\n\nBase64 encoded content:\n\n```javascript\ncordova.plugins.printer.print('base64://...');\n```\n\n__Note:__ On the browser platform the plugin only supports to print the contents of the web view.\n\n## Formatting\n\nIt's possible to pass format options to the print method that overrides the defaults:\n\n```javascript\ncordova.plugins.printer.print(content, options, callback);\n```\n\nThe defaults are defined as follows:\n\n```javascript\ncordova.plugins.printer.setDefaults({ monochrome: true });\n```\n\nThe list of possible options depend on the platform, the content type and the capabilities of the printer.\n\n| Name | Description | Type | Platform |\n|:---- |:----------- |:----:| --------:|\n| name | The name of the print job and of the document. | String | all |\n| copies | The number of copies for the print task. | Number | iOS\u003cbr\u003eWindows |\n| pageCount | Limits the pages to print even the document contains more.\u003cbr\u003eTo skip the last n pages you can assign a negative value on iOS. | Number | iOS\u003cbr\u003eAndroid |\n| duplex | Either double-sided on short site (duplex:'short'), double-sided on long site (duplex:'long') or single-sided (duplex:'none'). | String | all |\n| orientation | The orientation of the printed content, `portrait` or `landscape`. | String | all |\n| monochrome | If your application only prints black text, setting this property to _true_ can result in better performance in many cases. | Boolean | all |\n| photo | Set to _true_ to change the media type to photography for higher quality. | Boolean | iOS\u003cbr\u003eWindows |\n| autoFit | Set to _false_ to disable downscaling the image to fit into the content aread. | Boolean | Android |\n| printer | The network URL to the printer. | String | iOS |\n| maxHeight\u003cbr\u003emaxWidth | Defines the maximum size of the content area. | Unit | iOS |\n| margin | Set to _false_ to avoid margins. | Boolean | all |\n| margin.top\u003cbr\u003emargin.left\u003cbr\u003emargin.right\u003cbr\u003emargin.bottom | The margins for each printed page. Each printer might have its own minimum margins depends on media type and paper format. | Unit | iOS |\n| ui.hideNumberOfCopies | Set to _true_ to hide the control for the number of copies. | Boolean | iOS |\n| ui.hidePaperFormat | Set to _true_ to hide the control for the paper format. | Boolean | iOS |\n| ui.top\u003cbr\u003eui.left | The position of the printer picker. | Number | iPad |\n| ui.height\u003cbr\u003eui.width | The size of the printer picker. | Number | iPad |\n| paper.width\u003cbr\u003epaper.height | The dimensions of the paper – iOS will will try to choose a format which fits bests. | Unit | iOS |\n| paper.name | The name of the format like `IsoA4` or `Roll22Inch`.\u003cbr\u003ehttps://docs.microsoft.com/en-us/uwp/api/windows.graphics.printing.printmediasize | String | Windows |\n| paper.length | On roll-fed printers you can decide when the printer cuts the paper. | Unit | iOS |\n| font.name | The name of the font family | String | iOS |\n| font.size | The size of the font | Number | iOS\u003cbr\u003eAndroid |\n| font.italic\u003cbr\u003efont.bold | Set to _true_ to enable these font traits. | Boolean | iOS |\n| font.align | Possible alignments are `left`, `right`, `center` and `justified`. | String | iOS |\n| font.color | The color of the font in hexa-decimal RGB format - `\"FF0000\"` means red. | String | iOS |\n| header.height\u003cbr\u003efooter.height | The height of the header or footer on each page. | Unit | iOS |\n| header.labels\u003cbr\u003efooter.labels | An array of labels to display. Only use if there are more then one. | Array | iOS |\n| header.label.text\u003cbr\u003efooter.label.text | The plain text to display. Use `%ld` to indicate where to insert the page index.\u003cbr\u003eFor example `\"Page %ld\"` would result into `\"Page 1\"`, `\"Page 2\"`, ... | String | iOS |\n| header.label.top\u003cbr\u003eheader.label.right\u003cbr\u003eheader.label.left\u003cbr\u003eheader.label.bottom\u003cbr\u003efooter.label.* | The relative position where to place the label within the footer or header area. | Unit | iOS |\n| header.label.font\u003cbr\u003efooter.label.font | The font attributes for the label. | Object | iOS |\n| header.label.showPageIndex\u003cbr\u003efooter.label.showPageIndex | Set to _true_ if you want to display the page index.\u003cbr\u003e | Boolean | iOS |\n\nThe `Unit` type can be either a (float) number or a string with a special suffix.\n\n- Supported unit suffixes are `in` for inches, `mm` for millimeters, `cm` for centimeters and `pt` for points\n- `\"2in\"` are two inches whereas `2.0` or `\"2.0pt\"` are identical for two points\n- One inch are 72.0 points\n\n## Direct Print\n\nFor iOS its possible to send the content directly to the printer without any dialog. Todo so pass the network URL as an option:\n\n```javascript\ncordova.plugins.printer.print(content, { printer: 'ipp://...' });\n```\n\nTo let the user pick an available printer:\n\n```javascript\ncordova.plugins.printer.pick(function (url) {});\n```\n\nIt's possible to specify the position of the picker:\n\n```javascript\ncordova.plugins.printer.pick({ top: 40, left: 30 }, callback);\n```\n\n__Note:__ By passing an invalid URL, the application will throw an `Unable to connect to (null)` exception and possibly crash.\n\n## Printable Document Types\n\nThe list of supported document types differ between mobile platforms. As of writing, Windows UWP only supports HTML and plain text.\n\nTo get a list of all printable document types:\n\n```javascript\ncordova.plugins.printer.getPrintableTypes(callback);\n```\n\nTo check if printing is supported in general:\n\n```javascript\ncordova.plugins.printer.canPrintItem(callback);\n```\n\nOr in particular:\n\n```javascript\ncordova.plugins.printer.canPrintItem('file://css/index.css', callback);\n```\n\n## Sample\n\n```js\nvar options = {\n    font: {\n        size: 22,\n        italic: true,\n        align: 'center'\n    },\n    header: {\n        height: '6cm',\n        label: {\n            text: \"\\n\\nDie Freuden\",\n            font: {\n                bold: true,\n                size: 37,\n                align: 'center'\n            }\n        }\n    },\n    footer: {\n        height: '4cm',\n        label: {\n            text: 'Johann Wolfgang von Goethe, 1749-1832, deutscher Dichter, Naturforscher',\n            font: { align: 'center' }\n        }\n    }\n};\n\ncordova.plugins.printer.print(\"Es flattert um die Quelle\\nDie wechselnde Libelle,...\", options);\n```\n\nThe result will look like this for iOS:\n\n![ttt](https://github.com/katzer/cordova-plugin-printer/blob/example/images/sample.png)\n\n## Installation\n\nExecute from the projects root folder:\n\n    $ cordova plugin add cordova-plugin-printer\n\nOr install a specific version:\n\n    $ cordova plugin add cordova-plugin-printer@VERSION\n\nOr install the latest head version:\n\n    $ cordova plugin add https://github.com/katzer/cordova-plugin-printer.git\n\nOr install from local source:\n\n    $ cordova plugin add \u003cpath\u003e --nofetch --nosave\n\nThen execute:\n\n    cordova build\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\n## License\n\nThis software is released under the [Apache 2.0 License][apache2_license].\n\nMade with :yum: from Leipzig\n\n© 2013 [appPlant GmbH][appplant]\n\n\n[cordova]: https://cordova.apache.org\n[apache2_license]: http://opensource.org/licenses/Apache-2.0\n[appplant]: www.appplant.de\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkatzer%2Fcordova-plugin-printer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkatzer%2Fcordova-plugin-printer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkatzer%2Fcordova-plugin-printer/lists"}