ngx-print 21.2.0 → 22.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/.editorconfig +13 -0
  2. package/.eslintrc.json +50 -0
  3. package/.github/ISSUE_TEMPLATE/bug_report.md +31 -0
  4. package/.github/ISSUE_TEMPLATE/feature_request.md +19 -0
  5. package/.github/dependabot.yml +17 -0
  6. package/.github/workflows/PullRequest.yml +32 -0
  7. package/.github/workflows/stale.yml +25 -0
  8. package/.prettierignore +42 -0
  9. package/.prettierrc.json +14 -0
  10. package/CHANGELOG.md +126 -0
  11. package/README.md +90 -52
  12. package/_config.yml +1 -0
  13. package/angular.json +132 -0
  14. package/eslint.config.js +32 -0
  15. package/ng-package.json +7 -0
  16. package/package.json +60 -43
  17. package/projects/demo/public/favicon.ico +0 -0
  18. package/projects/demo/src/app/app.config.ts +11 -0
  19. package/projects/demo/src/app/app.routes.ts +3 -0
  20. package/projects/demo/src/app/demo.component.html +83 -0
  21. package/projects/demo/src/app/demo.component.scss +54 -0
  22. package/projects/demo/src/app/demo.component.ts +73 -0
  23. package/projects/demo/src/index.html +13 -0
  24. package/projects/demo/src/main.ts +5 -0
  25. package/projects/demo/src/styles.scss +1 -0
  26. package/projects/demo/tsconfig.app.json +19 -0
  27. package/projects/demo/tsconfig.spec.json +15 -0
  28. package/src/lib/ngx-print.base.ts +381 -0
  29. package/src/lib/ngx-print.directive.spec.ts +232 -0
  30. package/src/lib/ngx-print.directive.ts +72 -0
  31. package/src/lib/ngx-print.module.ts +8 -0
  32. package/src/lib/ngx-print.service.spec.ts +276 -0
  33. package/src/lib/ngx-print.service.ts +50 -0
  34. package/src/lib/print-options.ts +16 -0
  35. package/src/public_api.ts +8 -0
  36. package/tsconfig.json +38 -0
  37. package/tsconfig.lib.json +19 -0
  38. package/tsconfig.spec.json +10 -0
  39. package/tslint.json +17 -0
  40. package/fesm2022/ngx-print.mjs +0 -543
  41. package/fesm2022/ngx-print.mjs.map +0 -1
  42. package/types/ngx-print.d.ts +0 -228
  43. package/types/ngx-print.d.ts.map +0 -1
package/.editorconfig ADDED
@@ -0,0 +1,13 @@
1
+ # Editor configuration, see https://editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ charset = utf-8
6
+ indent_style = space
7
+ indent_size = 2
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
10
+
11
+ [*.md]
12
+ max_line_length = off
13
+ trim_trailing_whitespace = false
package/.eslintrc.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "root": true,
3
+ "ignorePatterns": ["projects/**/*"],
4
+ "overrides": [
5
+ {
6
+ "files": ["*.ts"],
7
+ "extends": [
8
+ "eslint:recommended",
9
+ "plugin:@typescript-eslint/recommended",
10
+ "plugin:@angular-eslint/recommended",
11
+ "plugin:@angular-eslint/template/process-inline-templates",
12
+ "plugin:prettier/recommended"
13
+ ],
14
+ "rules": {
15
+ "@typescript-eslint/no-unused-vars": "off",
16
+ "@typescript-eslint/no-explicit-any": "off",
17
+ "@typescript-eslint/no-unused-expressions": "off",
18
+ "@angular-eslint/directive-selector": [
19
+ "off",
20
+ {
21
+ "type": "attribute",
22
+ "prefix": "app",
23
+ "style": "camelCase"
24
+ }
25
+ ],
26
+ "@angular-eslint/component-selector": [
27
+ "error",
28
+ {
29
+ "type": "element",
30
+ "prefix": "app",
31
+ "style": "kebab-case"
32
+ }
33
+ ]
34
+ }
35
+ },
36
+ {
37
+ "files": ["*.html"],
38
+ "excludedFiles": ["*inline-template-*.component.html"],
39
+ "extends": ["plugin:@angular-eslint/template/recommended", "plugin:prettier/recommended"],
40
+ "rules": {
41
+ "prettier/prettier": [
42
+ "error",
43
+ {
44
+ "parser": "angular"
45
+ }
46
+ ]
47
+ }
48
+ }
49
+ ]
50
+ }
@@ -0,0 +1,31 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+ ---
8
+
9
+ **Describe the bug**
10
+ A clear and concise description of what the bug is.
11
+
12
+ **To Reproduce**
13
+ Steps to reproduce the behavior.
14
+
15
+ **Expected behavior**
16
+ A clear and concise description of what you expected to happen.
17
+
18
+ **Screenshots**
19
+ If applicable, add screenshots to help explain your problem.
20
+
21
+ **Ngx-Print Version**
22
+ Include the current affected version.
23
+
24
+ **Desktop (please complete the following information):**
25
+
26
+ - OS: [e.g. iOS]
27
+ - Browser [e.g. chrome, safari]
28
+ - Version [e.g. 22]
29
+
30
+ **Additional context**
31
+ Add any other context about the problem here.
@@ -0,0 +1,19 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+ ---
8
+
9
+ **Is your feature request related to a problem? Please describe.**
10
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
11
+
12
+ **Describe the solution you'd like**
13
+ A clear and concise description of what you want to happen.
14
+
15
+ **Describe alternatives you've considered**
16
+ A clear and concise description of any alternative solutions or features you've considered.
17
+
18
+ **Additional context**
19
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,17 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: 'npm'
4
+ directory: '/'
5
+ schedule:
6
+ interval: 'weekly'
7
+ day: 'monday'
8
+ time: '10:00'
9
+ timezone: 'America/New_York'
10
+ open-pull-requests-limit: 5
11
+ groups:
12
+ npm-dependencies:
13
+ patterns:
14
+ - '*'
15
+ ignore:
16
+ - dependency-name: '*'
17
+ update-types: ['version-update:semver-major']
@@ -0,0 +1,32 @@
1
+ name: Pull Request Checker
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - main
7
+
8
+ concurrency:
9
+ group: ${{github.repository_id}}-${{ github.workflow }}-${{ github.ref }}
10
+ cancel-in-progress: true
11
+
12
+ jobs:
13
+ build-npm:
14
+ runs-on: ubuntu-latest
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Setup Node.js
20
+ uses: actions/setup-node@v4
21
+ with:
22
+ node-version: 24.17.0
23
+
24
+ - name: Install npm dependencies
25
+ run: npm ci
26
+
27
+ # Run linting
28
+ - name: Run lint
29
+ run: npm run lint
30
+
31
+ - name: Run tests
32
+ run: npm run test
@@ -0,0 +1,25 @@
1
+ name: Mark stale issues and pull requests
2
+
3
+ on:
4
+ schedule:
5
+ - cron: '0 2 * * *'
6
+ workflow_dispatch:
7
+
8
+ permissions:
9
+ issues: write
10
+ pull-requests: write
11
+
12
+ jobs:
13
+ stale:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/stale@v9
17
+ with:
18
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
19
+ stale-issue-message: 'This issue has been automatically marked as stale due to inactivity. Please comment if you want to keep it open.'
20
+ stale-pr-message: 'This pull request has been automatically marked as stale due to inactivity.'
21
+ close-issue-message: 'Closing this issue due to prolonged inactivity.'
22
+ close-pr-message: 'Closing this pull request due to inactivity.'
23
+ days-before-stale: 30
24
+ days-before-close: 7
25
+ exempt-issue-labels: 'inspecting'
@@ -0,0 +1,42 @@
1
+ # See http://help.github.com/ignore-files/ for more about ignoring files.
2
+
3
+ # Compiled output
4
+ /dist
5
+ /tmp
6
+ /out-tsc
7
+ /bazel-out
8
+
9
+ # Node
10
+ /node_modules
11
+ npm-debug.log
12
+ yarn-error.log
13
+
14
+ # IDEs and editors
15
+ .idea/
16
+ .project
17
+ .classpath
18
+ .c9/
19
+ *.launch
20
+ .settings/
21
+ *.sublime-workspace
22
+
23
+ # Visual Studio Code
24
+ .vscode/*
25
+ !.vscode/settings.json
26
+ !.vscode/tasks.json
27
+ !.vscode/launch.json
28
+ !.vscode/extensions.json
29
+ .history/*
30
+
31
+ # Miscellaneous
32
+ /.angular/cache
33
+ .sass-cache/
34
+ /connect.lock
35
+ /coverage
36
+ /libpeerconnection.log
37
+ testem.log
38
+ /typings
39
+
40
+ # System files
41
+ .DS_Store
42
+ Thumbs.db
@@ -0,0 +1,14 @@
1
+ {
2
+ "tabWidth": 2,
3
+ "useTabs": false,
4
+ "singleQuote": true,
5
+ "semi": true,
6
+ "bracketSpacing": true,
7
+ "arrowParens": "avoid",
8
+ "trailingComma": "es5",
9
+ "bracketSameLine": true,
10
+ "printWidth": 150,
11
+ "endOfLine": "auto",
12
+ "htmlWhitespaceSensitivity": "ignore",
13
+ "quoteProps": "preserve"
14
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,126 @@
1
+ # 22.0.0 (2026-06-22)
2
+
3
+ - Support for Angular 22.
4
+
5
+ # 21.1.0 (2026-01-07)
6
+
7
+ ### New features
8
+
9
+ - iFrame printing
10
+
11
+ ### New features
12
+
13
+ - Support for Angular 21.
14
+
15
+ ### Bug fixes
16
+
17
+ - nullpointer defaultSelected
18
+
19
+ # 20.1.0 (2025-09-01)
20
+
21
+ ### New features
22
+
23
+ - Can now use `ngx-print` without nonces for inline script.
24
+
25
+ ### Maintenance
26
+
27
+ - Updated npm dependencies (multiple Dependabot updates).
28
+ - Removed unsafe inline script.
29
+
30
+ # 20.0.0 (2025-07-15)
31
+
32
+ ### New features
33
+
34
+ - Support for Angular 20.
35
+ - Aligned major versions with Angular release versions (library major matches Angular major).
36
+
37
+ ### Maintenance
38
+
39
+ - Implemented various feature requests and updated npm dependencies.
40
+
41
+ # 3.1.0 (2025-06-12)
42
+
43
+ ### New features
44
+
45
+ - Now supports printing on any HTML element, not only button elements.
46
+ - Replaced `document.write` usage with DOM manipulation for rendering print content.
47
+
48
+ ### Bug fixes
49
+
50
+ - Fixed issues related to printing from specific button elements.
51
+
52
+ # 3.0.0 (2025-05-21)
53
+
54
+ ### New features
55
+
56
+ - Support for Angular 19.
57
+
58
+ # 2.0.0 (2024-12-04)
59
+
60
+ ### New features
61
+
62
+ - Added support for Content-Security-Policy via nonce injection.
63
+ - Support for Angular 18.
64
+
65
+ ### Contributors
66
+
67
+ - Contributions by EpicVoyage and Core121.
68
+
69
+ # 1.5.1 (2024-01-05)
70
+
71
+ ### New features
72
+
73
+ - Added support for printing canvas contents.
74
+ - Added option to open the print view in a new tab.
75
+
76
+ ### Bug fixes
77
+
78
+ - Fixed `printTitle` property issue.
79
+
80
+ ### Maintenance
81
+
82
+ - Documentation updates.
83
+
84
+ # 1.5.0 (2023-12-03)
85
+
86
+ - Now supports Angular 17.
87
+ - Added printService.
88
+
89
+ # 1.4.0 (2023-12-03)
90
+
91
+ - Now supports Angular 16.
92
+ - Added functionality to handle select form fields.
93
+ - Added standalone support.
94
+ - Added `closeWindow` and `bodyClass` options and fixed tests.
95
+
96
+ # 1.3.1 (2023-01-04)
97
+
98
+ ### Bug fixes
99
+
100
+ - Fixed build by allowing the package to run in partial Ivy mode due to npm not supporting full Ivy mode, deprecating
101
+ v1.3.0.
102
+
103
+ # 1.3.0 (2022-12-20)
104
+
105
+ ### New features
106
+
107
+ - Supports `previewOnly` tag, allowing for the print preview to show without the print dialog.
108
+
109
+ ### Dependency Updates
110
+
111
+ - Angular Ivy support with Angular 15.
112
+
113
+ # 1.2.1 (2021-05-10)
114
+
115
+ ### Bug fixes
116
+
117
+ - Working build for non‑beta releases.
118
+
119
+ # 1.1.0 (2018-12-04)
120
+
121
+ ### New features
122
+
123
+ - Support styles (
124
+ CSS) ([#5](https://github.com/selemxmn/ngx-print/issues/5)) ([71cefdf](https://github.com/selemxmn/ngx-print/commit/71cefdf)).
125
+ - Permit a dynamic title of printing window instead of the old static
126
+ `Print tab` ([2098f3e](https://github.com/selemxmn/ngx-print/commit/2098f3e)).
package/README.md CHANGED
@@ -1,12 +1,15 @@
1
1
  [![](https://badgen.net/npm/dt/ngx-print)](https://www.npmjs.com/package/ngx-print) [![](https://travis-ci.org/selemxmn/ngx-print.svg?branch=master)](https://travis-ci.org/selemxmn/ngx-print) [![Coverage Status](https://coveralls.io/repos/github/selemxmn/ngx-print/badge.svg?branch=unit-tests)](https://coveralls.io/github/selemxmn/ngx-print?branch=unit-tests)
2
2
 
3
- # ngx-print : *plug n' play Angular (2++) directive to print your stuff*
4
- This directive makes printing your HTML sections smooth and easy in your Angular application. It is inspired from the old [AngularJS ngPrint](https://github.com/gilf/ngPrint) directive, thus it is intendend to be used with the new Angular -2/4/5/6/7-... ***Enjoy ! contributions are so welcomed :)***
3
+ [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/edit/i7vymeqf-anasgtzf?file=src%2Fmain.ts)
4
+
5
+ # ngx-print : *plug n' play Angular directive to print your stuff*
6
+ This directive makes printing your HTML sections smooth and easy in your Angular application. It is inspired from the old [AngularJS ngPrint](https://github.com/gilf/ngPrint) directive.
7
+ ***Enjoy! Contributions are so welcomed :)***
5
8
 
6
9
  ## Dependencies
7
10
 
8
11
  | ngx-print | Angular |
9
- |-----------|----------------|
12
+ | --------- | -------------- |
10
13
  | 1.2.1 | 7.0.0 - 14.1.0 |
11
14
  | 1.3.x | 15.0.0 |
12
15
  | 1.4.x | 16.0.0 |
@@ -15,6 +18,7 @@ This directive makes printing your HTML sections smooth and easy in your Angular
15
18
  | 3.x.x | 19.0.0 |
16
19
  | 20.x.x | 20.0.0 |
17
20
  | 21.x.x | 21.0.0 |
21
+ | 22.x.x | 22.0.0 |
18
22
 
19
23
  ## Version Alignment Notice
20
24
 
@@ -53,7 +57,7 @@ export class PrintExampleComponent {}
53
57
  <button>print</button> <!--Your relevant print button-->
54
58
  ```
55
59
 
56
- - Now, what you have to do is tagging your *wanted-to-print* section by an `id` attribute, then link that `id` to a directive parameter in your button :
60
+ - Now, what you have to do is tagging your *wanted-to-print* section by an `id` attribute, then link that `id` to a directive parameter in your button:
57
61
 
58
62
  ```html
59
63
  <!--
@@ -68,16 +72,14 @@ export class PrintExampleComponent {}
68
72
  3)- Affect your ID to printSectionId
69
73
  -->
70
74
  <button printSectionId="print-section" ngxPrint>print</button>
71
-
72
75
  ```
73
76
 
74
77
  ## Optional properties
75
78
 
76
- - You want a customized title for your printing window ? you have the choice by adding a new attribute to your print button `printTitle`:
77
-
79
+ - You want a customized title for your printing window? Add `printTitle`:
78
80
 
79
81
  ```html
80
- <div id="print-section">
82
+ <div id="print-section">
81
83
  <!-- ... -->
82
84
  </div>
83
85
 
@@ -86,11 +88,10 @@ export class PrintExampleComponent {}
86
88
  ngxPrint>print</button>
87
89
  ```
88
90
 
89
-
90
- - Also, would you like to customize the printing window style sheet (CSS) ? Hence you can do so by adding infinite styles to another attribute called `printStyle`:
91
-
91
+ - Customize the printing stylesheet (CSS) by adding styles to `printStyle`:
92
+
92
93
  ```html
93
- <div id="print-section">
94
+ <div id="print-section">
94
95
  <!-- ... -->
95
96
  </div>
96
97
 
@@ -100,11 +101,19 @@ export class PrintExampleComponent {}
100
101
  ```
101
102
 
102
103
  Here some simple styles were added to every `h1` & `h2` tags within the `div` where `print-section` is tagged to its `id` attribute.
103
-
104
+
105
+ `printStyle` also accepts a raw CSS string, which is injected into the print document's `<style>` tag as-is. This is useful for anything the object form can't express well, such as multiple selectors per rule, media queries, or `!important`:
106
+
107
+ ```html
108
+ <button printStyle="h1, h2 { color: red; } @media print { .no-print { display: none; } }"
109
+ printSectionId="print-section"
110
+ ngxPrint>print</button>
111
+ ```
112
+
104
113
  - If you would like to use your existing CSS with media print you can add the `useExistingCss` attribute:
105
114
 
106
115
  ```html
107
- <div id="print-section">
116
+ <div id="print-section">
108
117
  <!-- ... -->
109
118
  </div>
110
119
 
@@ -113,10 +122,10 @@ Here some simple styles were added to every `h1` & `h2` tags within the `div` wh
113
122
  ngxPrint>print</button>
114
123
  ```
115
124
 
116
- - If you want to customize the printing window style sheet (CSS) by importing the css provided in assets/css use `styleSheetFile`:
125
+ - Import external stylesheets with `styleSheetFile` (comma-separated list):
117
126
 
118
127
  ```html
119
- <div id="print-section">
128
+ <div id="print-section">
120
129
  <!-- ... -->
121
130
  </div>
122
131
 
@@ -124,54 +133,63 @@ Here some simple styles were added to every `h1` & `h2` tags within the `div` wh
124
133
  printSectionId="print-section"
125
134
  ngxPrint>print</button>
126
135
  ```
127
-
128
- - If you would like to show a preview without a print dialog use `previewOnly`:
136
+
137
+ - Show a preview without opening the print dialog using `previewOnly`:
129
138
 
130
139
  ```html
131
- <div id="print-section">
140
+ <div id="print-section">
132
141
  <!-- ... -->
133
142
  </div>
134
143
 
135
144
  <button [previewOnly]="true"
136
145
  printSectionId="print-section"
137
146
  ngxPrint>print</button>
138
-
139
147
  ```
140
148
 
141
149
  - Some print operations open a second dialog, and automatically closing the popup window happens before the second dialog opens. Set `closeWindow` to false to handle print operations that open a second dialog, like "Microsoft Print to PDF", or "Print using system dialog...":
142
150
 
143
151
  ```html
144
-
145
- <div id="print-section">
152
+ <div id="print-section">
146
153
  <!-- ... -->
147
154
  </div>
148
155
 
149
156
  <button [closeWindow]="false"
150
157
  printSectionId="print-section"
151
158
  ngxPrint>print</button>
152
-
153
159
  ```
154
160
 
155
- - Set `bodyClass` to whatever class values are needed for some of your css rules that expect an ancestor to have a certain class. For example, a theme selector:
161
+ - Set `bodyClass` to whatever class values are needed for some of your CSS rules that expect an ancestor to have a certain class. For example, a theme selector:
156
162
 
157
163
  ```html
158
- <div id="print-section">
159
- <!-- ... -->
164
+ <div id="print-section">
165
+ <!-- ... -->
160
166
  </div>
161
167
 
162
- <button [bodyClass]="theme-dark"
168
+ <button bodyClass="theme-dark"
163
169
  printSectionId="print-section"
164
170
  ngxPrint>print</button>
165
171
  ```
166
172
 
167
- - To print in a new tab rather than a new window set the property `openNewTab` to true. By default `openNewTab` is false and ngxPrint will open a new print window.
173
+ - Use `printMethod` to control how the print window is opened. The default is `'window'` (a new popup window). Set it to `'tab'` to open a new browser tab instead, or to `'iframe'` to print silently in the background using a hidden iframe (no popup at all):
168
174
 
169
175
  ```html
170
- <button [openNewTab]="true"
176
+ <!-- Default: opens a new popup window -->
177
+ <button printMethod="window"
178
+ printSectionId="print-section"
179
+ ngxPrint>print</button>
180
+
181
+ <!-- Opens a new browser tab -->
182
+ <button printMethod="tab"
183
+ printSectionId="print-section"
184
+ ngxPrint>print</button>
185
+
186
+ <!-- Prints silently via a hidden iframe (no popup) -->
187
+ <button printMethod="iframe"
188
+ printSectionId="print-section"
171
189
  ngxPrint>print</button>
172
190
  ```
173
191
 
174
- - To run a function after printing completes, subscribe to the `printCompleted` event. Please note it is impossible to differentiate between the Cancel or Print buttong being clicked on the print window. This event will fire regardless of which button was clicked:
192
+ - To run a function after printing completes, subscribe to the `printCompleted` event. Please note it is impossible to differentiate between the Cancel or Print button being clicked on the print window. This event will fire regardless of which button was clicked:
175
193
 
176
194
  ```html
177
195
  <button (printCompleted)="onPrintComplete()"
@@ -182,66 +200,86 @@ Here some simple styles were added to every `h1` & `h2` tags within the `div` wh
182
200
 
183
201
  ## Using NgxPrint as a service (v1.5+)
184
202
 
185
- Inject the NgxPrintService into your component or service:
203
+ Inject the `NgxPrintService` into your component or service:
186
204
 
187
205
  ```ts
206
+ import { inject } from '@angular/core';
207
+ import { NgxPrintService, PrintOptions } from 'ngx-print';
208
+
188
209
  private readonly printService = inject(NgxPrintService);
189
210
  ```
190
211
 
191
212
  ### Printing a Section
192
213
 
193
- ```typescript
194
- import { PrintOptions } from './path-to-your/print-options.model';
214
+ ```ts
215
+ import { PrintOptions } from 'ngx-print';
195
216
 
196
217
  printMe(): void {
197
- const customPrintOptions: PrintOptions = new PrintOptions({
198
- printSectionId: 'print-section',
199
- // add any other print options as needed
218
+ const customPrintOptions = new PrintOptions({
219
+ printSectionId: 'print-section',
220
+ // add any other print options as needed
200
221
  });
201
- this.printService.print(customPrintOptions)
222
+ this.printService.print(customPrintOptions);
202
223
  }
203
224
  ```
204
225
 
205
226
  ### Print Options Object
206
- The print options object allows you to specify how the print job should be handled. All of which have default values that you can optionally override, although printSectionId is required. It contains the following properties:
227
+
228
+ The `PrintOptions` object allows you to specify how the print job should be handled. All properties have default values and are optional, although `printSectionId` is required. It contains the following properties:
229
+
207
230
  ```typescript
208
- printSectionId: string = null;
209
- printTitle: string = null;
231
+ printSectionId: string = '';
232
+ printTitle: string = '';
210
233
  useExistingCss: boolean = false;
211
234
  bodyClass: string = '';
212
- openNewTab: boolean = false;
235
+ printMethod: 'window' | 'tab' | 'iframe' = 'window';
213
236
  previewOnly: boolean = false;
214
237
  closeWindow: boolean = true;
215
238
  printDelay: number = 0;
216
239
  ```
217
240
 
241
+ | Property | Type | Default | Description |
242
+ | ---------------- | ------------------------------- | ---------- | ---------------------------------------------------------------------------- |
243
+ | `printSectionId` | `string` | `''` | **Required.** The `id` of the element to print. |
244
+ | `printTitle` | `string` | `''` | Title shown in the print document. |
245
+ | `useExistingCss` | `boolean` | `false` | Copies `<style>` and `<link>` tags from the host page. |
246
+ | `bodyClass` | `string` | `''` | CSS class(es) applied to the print `<body>`. |
247
+ | `printMethod` | `'window' \| 'tab' \| 'iframe'` | `'window'` | Controls how printing is triggered: popup window, new tab, or silent iframe. |
248
+ | `previewOnly` | `boolean` | `false` | Opens the print target without triggering the print dialog. |
249
+ | `closeWindow` | `boolean` | `true` | Closes the popup window after printing (ignored for `iframe`). |
250
+ | `printDelay` | `number` | `0` | Delay in milliseconds before the print dialog is opened. |
251
+
218
252
  ### Setting PrintStyles or StyleSheets
219
253
 
220
- ```typescript
221
- // Optional property for css as a key-value pair
254
+ ```ts
255
+ // Optional: CSS as a key-value pair
222
256
  this.printService.printStyle = styleSheet;
223
257
 
224
- // Optional property for a css file location
258
+ // Optional: CSS as a raw string
259
+ this.printService.printStyle = 'h1, h2 { color: red; }';
260
+
261
+ // Optional: path to a CSS file
225
262
  this.printService.styleSheetFile = fileLocation;
226
263
  ```
227
264
 
228
- ### Subscribing to print event
265
+ ### Subscribing to the print event
229
266
 
230
- ```typescript
231
- this.printService.printComplete$.pipe(take(1)).subscribe(() => {
232
- console.log('Print completed!');
233
- });
267
+ ```ts
268
+ this.printService.printComplete$.pipe(take(1)).subscribe(() => {
269
+ console.log('Print completed!');
270
+ });
234
271
  ```
235
272
 
236
273
  ## Content-Security-Policy (CSP) Support
237
- If Angular is configured to use a [CSP Nonce](https://angular.io/api/core/CSP_NONCE), ngx-print will automatically inject the `[printStyle]` CSS rules with this Nonce authorization.
274
+
275
+ If Angular is configured to use a [CSP Nonce](https://angular.io/api/core/CSP_NONCE), ngx-print will automatically inject the `[printStyle]` CSS rules and stylesheet `<link>` tags with this nonce so they are permitted by the browser's Content Security Policy.
238
276
 
239
277
  ## Contributors :1st_place_medal:
240
278
 
241
- Huge thanks to: [deeplotia](https://github.com/deeplotia) , [Ben L](https://github.com/broem) , [Gavyn McKenzie](https://github.com/gavmck) , [silenceway](https://github.com/silenceway), [Muhammad Ahsan Ayaz](https://github.com/AhsanAyaz), [Core121](https://github.com/Core121) and to all `ngx-print` users
279
+ Huge thanks to: [deeplotia](https://github.com/deeplotia), [Ben L](https://github.com/broem), [Gavyn McKenzie](https://github.com/gavmck), [silenceway](https://github.com/silenceway), [Muhammad Ahsan Ayaz](https://github.com/AhsanAyaz), [Core121](https://github.com/Core121), [Andreas Dorner](https://github.com/endlacer) and to all `ngx-print` users
242
280
 
243
281
  ## Donation
244
282
 
245
- Did this project help you reducing time? I won't say no to a cup of coffee 🍵 :)
283
+ Did this project help you reduce time? I won't say no to a cup of coffee 🍵 :)
246
284
 
247
285
  [![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.me/selemxmn/2)
package/_config.yml ADDED
@@ -0,0 +1 @@
1
+ theme: jekyll-theme-cayman