https://github.com/kevinokerlund/print-job
Print an element on the page without the need for popup windows, or moving HTML around.
https://github.com/kevinokerlund/print-job
browser javascript printer printing
Last synced: 7 months ago
JSON representation
Print an element on the page without the need for popup windows, or moving HTML around.
- Host: GitHub
- URL: https://github.com/kevinokerlund/print-job
- Owner: kevinokerlund
- License: mit
- Created: 2015-06-23T23:30:17.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2019-01-28T19:32:31.000Z (over 6 years ago)
- Last Synced: 2024-03-15T19:13:41.210Z (over 1 year ago)
- Topics: browser, javascript, printer, printing
- Language: JavaScript
- Homepage:
- Size: 30.3 KB
- Stars: 7
- Watchers: 4
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# print-job
This small JavaScript library prints a single HTML container.
## Features
* No popup windows or iFrames
* No moving and replacing HTML
* Preserve styles inherited from parent elements## Install
```bash
npm install --save print-job
```## Usage
#### In the browser
If the library is directly sourced to the window, it operates on the `PrintJob` global variable:
```javascript
window.PrintJob
````#### In ES6
```javascript
import PrintJob from 'print-job';
```## Documentation
### Print a container
You can pass in any valid selector, but only the first element found will be printed.
```javascript
PrintJob.print('#areaYouWantToPrint');
```You can alternatively pass in an element instead of a selector:
```javascript
let element = document.getElementById('areaYouWantToPrint');
PrintJob.print(element);
```---
### Print an external image
Print just an image by supplying an external URL to the `.image()` method. This is handy for printing a large version of
an image found on the page.
```javascript
PrintJob.image('url/to/image.jpg');
```_**Note:** Because the image has to be fetched, your application code will continue to run after calling this method.
The image will be printed the moment it loads._### Upcoming Features
* Use custom print CSS
* Lifecycle callbacks
* Before print
* After print
* Preset jobs (set up the job and print later)