Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: crabbly/Print.js
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.0.52
Choose a base ref
...
head repository: crabbly/Print.js
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
12 changes: 12 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"ie": "8"
}
}
]
]
}
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.idea/
node_modules/
dist/
dist/
yarn.lock
coverage/
.vscode
package-lock.json
10 changes: 9 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
.idea/
.gitignore
.travis.yml
.travis.yml
test/
bower.json
webpack.config.js
karma.conf.js
yarn.lock
coverage/
.vscode
package-lock.json
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
language: node_js
node_js:
- 8
- 10
branches:
only:
- master
- master
sudo: required
after_success:
- npm run coveralls
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016 Rodrigo Vieira (@crabbly)
Copyright (c) 2016-present, Rodrigo Vieira (@crabbly)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
48 changes: 30 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Print.js

[![Build Status](https://travis-ci.org/crabbly/Print.js.svg?branch=master)](https://travis-ci.org/crabbly/Print.js) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](LICENSE) [![Standard - JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](http://standardjs.com/) [![npm](https://img.shields.io/npm/v/print-js.svg)](https://www.npmjs.com/package/print-js)
[![Build Status](https://travis-ci.org/crabbly/Print.js.svg?branch=master)](https://travis-ci.org/crabbly/Print.js)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](LICENSE)
[![Standard - JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](http://standardjs.com/)
[![npm](https://img.shields.io/npm/v/print-js.svg)](https://www.npmjs.com/package/print-js)

A tiny javascript library to help printing from the web.

>For documentation and examples please visit: [printjs.crabbly.com](http://printjs.crabbly.com)
> For documentation and examples please visit: [printjs.crabbly.com](http://printjs.crabbly.com)
## Installation

@@ -23,41 +25,41 @@ To install via yarn:
yarn add print-js
```

When installing via npm or yarn, import the library into your project:
Import the library into your project:

```
```js
import printJS from 'print-js'
```

## Documentation

You can find documentation at [printjs.crabbly.com](http://printjs.crabbly.com/#documentation).


## Contributing to Print.js

Contributions to Print.js are welcome and encouraged.
[![devDependencies Status](https://david-dm.org/crabbly/print.js/dev-status.svg)](https://david-dm.org/crabbly/print.js?type=dev)
[![dependencies Status](https://david-dm.org/crabbly/print.js/status.svg)](https://david-dm.org/crabbly/print.js)

Contributions to Print.js are greatly welcomed and encouraged.

##### Using issues

The [issue tracker](https://github.com/crabbly/Print.js/issues) is the preferred channel for reporting bugs, requesting new features and submitting pull requests.

Keep in mind that we would like to keep this a lightweight library.

Please do not use the issues channel for support requests. For help using Print.js, please ask questions on Stack Overflow and use the tag `printjs`.

Please do not use the issues channel for support requests. For help with using Print.js, please ask questions on Stack Overflow and use the tag `printjs`.

##### Reporting bugs

Well structured, detailed bug reports are hugely valuable for the project.

- Check the issue search to see if it has already been reported
- Isolate the problem to a simple test case
* Check the issue search to see if it has already been reported.
* Isolate the problem to a simple test case.
* Create a codepen, fiddle, codesandbox or similar online example replicating the issue.

Please provide any additional details associated with the bug.


##### Pull requests

Clear, concise pull requests are excellent at continuing the project's community driven growth.
@@ -66,20 +68,30 @@ Please make your commits in logical sections with clear commit messages.

##### Setting up a dev environment

```
```bash
npm install
npm run watch
```

If you want to test your modified code:
##### Tests

```
npm install http-server -g
http-server
The library is written following the [Javascript Standard](https://standardjs.com) code style. When running tests, we will also test for any style issues or warnings.

Automated tests are written using the [Jasmine](https://jasmine.github.io) framework and [Karma](https://karma-runner.github.io) runner.

To run the automated tests:

```bash
npm run test
```

Navigate to `http://localhost:8080/test.html`
To manually test the library features:

```bash
npm start
```

This will serve `test\manual\test.html` and open `http://localhost:8080/test/manual` in your default browser.

## License

8 changes: 4 additions & 4 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{
"name": "print-js",
"description": "A tiny javascript library to help printing from the web.",
"main": "src/print.js",
"main": "dist/print.js",
"authors": [
"Rodrigo Vieira <rodrigo@crabbly.com>"
],
"license": "MIT",
"keywords": [
"print.js",
"printjs"
"printjs",
"print-js"
],
"homepage": "https://github.com/crabbly/Print.js",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
"test"
]
}
35 changes: 0 additions & 35 deletions index.d.ts

This file was deleted.

43 changes: 43 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// const path = require('path')

module.exports = function (config) {
config.set({
frameworks: ['jasmine'],
files: [
'test/**/*.spec.js'
],
exclude: [],
preprocessors: {
'test/**/*.js': ['webpack', 'sourcemap', 'coverage']
},
reporters: ['progress', 'coverage'],
coverageReporter: {
dir: 'coverage/',
type: 'lcov',
subdir: '.',
includeAllSources: true,
fixWebpackSourcePaths: true,
combineBrowserReports: true
},
port: 9876,
colors: true,
logLevel: config.LOG_ERROR,
autoWatch: false,
browsers: ['ChromeHeadless'],
singleRun: true,
concurrency: 1,
webpack: {
mode: 'development'
// TODO: Configure istanbul to interpret how webpack bundles files
// module: {
// rules: [
// {
// test: /\.js$/,
// use: { loader: 'istanbul-instrumenter-loader' },
// include: path.resolve('src/js/index.js')
// }
// ]
// }
}
})
}
54 changes: 36 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -2,37 +2,55 @@
"name": "print-js",
"homepage": "http://printjs.crabbly.com",
"description": "A tiny javascript library to help printing from the web.",
"version": "1.0.52",
"version": "1.6.0",
"main": "dist/print.js",
"types": "./index.d.ts",
"types": "src/index.d.ts",
"repository": "https://github.com/crabbly/Print.js",
"license": "MIT",
"dependences": {},
"devDependencies": {
"babel-core": "^6.26.3",
"babel-loader": "^7.1.5",
"babel-preset-env": "^1.7.0",
"css-loader": "^1.0.0",
"mini-css-extract-plugin": "^0.4.1",
"node-sass": "^4.9.3",
"optimize-css-assets-webpack-plugin": "^5.0.0",
"sass-loader": "^7.1.0",
"standard": "^7.1.2",
"uglifyjs-webpack-plugin": "^1.3.0",
"webpack": "^4.16.5",
"webpack-cli": "^3.1.0"
"@babel/core": "7.11.6",
"@babel/preset-env": "7.11.5",
"babel-loader": "8.1.0",
"coveralls": "3.1.0",
"css-loader": "4.2.2",
"istanbul-instrumenter-loader": "3.0.1",
"jasmine-core": "3.6.0",
"karma": "5.2.1",
"karma-chrome-launcher": "3.1.0",
"karma-coverage": "2.0.3",
"karma-jasmine": "4.0.1",
"karma-phantomjs-launcher": "1.0.4",
"karma-sourcemap-loader": "0.3.8",
"karma-webpack": "4.0.2",
"mini-css-extract-plugin": "0.11.0",
"node-sass": "4.14.1",
"optimize-css-assets-webpack-plugin": "5.0.4",
"sass-loader": "10.0.2",
"standard": "14.3.4",
"terser-webpack-plugin": "4.1.0",
"webpack": "4.44.1",
"webpack-cli": "3.3.12",
"webpack-dev-server": "3.11.0"
},
"scripts": {
"test": "standard",
"test": "standard && karma start",
"dev": "webpack --mode development --progress --hide-modules --devtool source-map",
"watch": "webpack --mode development --watch --progress --hide-modules",
"production": "webpack --mode production --progress --hide-modules"
"production": "webpack --mode production --progress --hide-modules",
"coverage": "open coverage/lcov-report/index.html",
"coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"start": "webpack-dev-server --public http://localhost:8080/test/manual --open",
"standard:fix": "standard --fix"
},
"author": "Rodrigo Vieira <rodrigo@crabbly.com>",
"standard": {
"ignore": [
"/dist/print.js"
]
],
"env": {
"browser": true,
"jasmine": true
}
},
"keywords": [
"printjs",
48 changes: 48 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
declare function printJS(configuration: printJS.Configuration): void;
declare function printJS(source: string, type?: printJS.PrintTypes): void;

declare namespace printJS {
type PrintTypes = 'pdf' | 'html' | 'image' | 'json' | 'raw-html';

interface Configuration {
printable: any;
fallbackPrintable?: string;
type?: PrintTypes;
documentTitle?: string;
header?: any;
headerStyle?: string;
footer?: any;
footerStyle?: string;
maxWidth?: number;
targetStyle?: string | string[];
targetStyles?: string | string[];
properties?: any;
gridHeaderStyle?: string;
gridStyle?: string;
showModal?: boolean;
onLoadingStart?: () => void;
onLoadingEnd?: () => void;
modalMessage?: string;
frameId?: string;
frameRemoveDelay?: number;
ignoreElements?: string | string[];
repeatTableHeader?: boolean;
css?: string | string[];
style?: string;
scanStyles?: boolean;
onError?: (error: any, xmlHttpRequest?: XMLHttpRequest) => void;
onPrintDialogClose?: () => void;
onIncompatibleBrowser?: () => void;
base64?: boolean;

// Deprecated
onPdfOpen?: () => void;
font?: string;
font_size?: string;
honorMarginPadding?: boolean;
honorColor?: boolean;
imageStyle?: string;
}
}

export = printJS;
Loading