ngx-print 21.1.0 → 22.0.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.
- package/README.md +79 -52
- package/fesm2022/ngx-print.mjs +130 -114
- package/fesm2022/ngx-print.mjs.map +1 -1
- package/package.json +3 -2
- package/types/ngx-print.d.ts +18 -42
- package/types/ngx-print.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
[](https://www.npmjs.com/package/ngx-print) [](https://travis-ci.org/selemxmn/ngx-print) [](https://coveralls.io/github/selemxmn/ngx-print?branch=unit-tests)
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
[](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
|
-
|
|
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
|
|
77
|
-
|
|
79
|
+
- You want a customized title for your printing window? Add `printTitle`:
|
|
78
80
|
|
|
79
81
|
```html
|
|
80
|
-
<div
|
|
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
|
-
|
|
91
|
-
|
|
91
|
+
- Customize the printing stylesheet (CSS) by adding styles to `printStyle`:
|
|
92
|
+
|
|
92
93
|
```html
|
|
93
|
-
<div
|
|
94
|
+
<div id="print-section">
|
|
94
95
|
<!-- ... -->
|
|
95
96
|
</div>
|
|
96
97
|
|
|
@@ -100,11 +101,11 @@ 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
|
+
|
|
104
105
|
- If you would like to use your existing CSS with media print you can add the `useExistingCss` attribute:
|
|
105
106
|
|
|
106
107
|
```html
|
|
107
|
-
<div
|
|
108
|
+
<div id="print-section">
|
|
108
109
|
<!-- ... -->
|
|
109
110
|
</div>
|
|
110
111
|
|
|
@@ -113,10 +114,10 @@ Here some simple styles were added to every `h1` & `h2` tags within the `div` wh
|
|
|
113
114
|
ngxPrint>print</button>
|
|
114
115
|
```
|
|
115
116
|
|
|
116
|
-
-
|
|
117
|
+
- Import external stylesheets with `styleSheetFile` (comma-separated list):
|
|
117
118
|
|
|
118
119
|
```html
|
|
119
|
-
<div
|
|
120
|
+
<div id="print-section">
|
|
120
121
|
<!-- ... -->
|
|
121
122
|
</div>
|
|
122
123
|
|
|
@@ -124,54 +125,63 @@ Here some simple styles were added to every `h1` & `h2` tags within the `div` wh
|
|
|
124
125
|
printSectionId="print-section"
|
|
125
126
|
ngxPrint>print</button>
|
|
126
127
|
```
|
|
127
|
-
|
|
128
|
-
-
|
|
128
|
+
|
|
129
|
+
- Show a preview without opening the print dialog using `previewOnly`:
|
|
129
130
|
|
|
130
131
|
```html
|
|
131
|
-
<div
|
|
132
|
+
<div id="print-section">
|
|
132
133
|
<!-- ... -->
|
|
133
134
|
</div>
|
|
134
135
|
|
|
135
136
|
<button [previewOnly]="true"
|
|
136
137
|
printSectionId="print-section"
|
|
137
138
|
ngxPrint>print</button>
|
|
138
|
-
|
|
139
139
|
```
|
|
140
140
|
|
|
141
141
|
- 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
142
|
|
|
143
143
|
```html
|
|
144
|
-
|
|
145
|
-
<div id="print-section">
|
|
144
|
+
<div id="print-section">
|
|
146
145
|
<!-- ... -->
|
|
147
146
|
</div>
|
|
148
147
|
|
|
149
148
|
<button [closeWindow]="false"
|
|
150
149
|
printSectionId="print-section"
|
|
151
150
|
ngxPrint>print</button>
|
|
152
|
-
|
|
153
151
|
```
|
|
154
152
|
|
|
155
|
-
- Set `bodyClass` to whatever class values are needed for some of your
|
|
153
|
+
- 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
154
|
|
|
157
155
|
```html
|
|
158
|
-
<div
|
|
159
|
-
<!-- ... -->
|
|
156
|
+
<div id="print-section">
|
|
157
|
+
<!-- ... -->
|
|
160
158
|
</div>
|
|
161
159
|
|
|
162
|
-
<button
|
|
160
|
+
<button bodyClass="theme-dark"
|
|
163
161
|
printSectionId="print-section"
|
|
164
162
|
ngxPrint>print</button>
|
|
165
163
|
```
|
|
166
164
|
|
|
167
|
-
-
|
|
165
|
+
- 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
166
|
|
|
169
167
|
```html
|
|
170
|
-
|
|
168
|
+
<!-- Default: opens a new popup window -->
|
|
169
|
+
<button printMethod="window"
|
|
170
|
+
printSectionId="print-section"
|
|
171
|
+
ngxPrint>print</button>
|
|
172
|
+
|
|
173
|
+
<!-- Opens a new browser tab -->
|
|
174
|
+
<button printMethod="tab"
|
|
175
|
+
printSectionId="print-section"
|
|
176
|
+
ngxPrint>print</button>
|
|
177
|
+
|
|
178
|
+
<!-- Prints silently via a hidden iframe (no popup) -->
|
|
179
|
+
<button printMethod="iframe"
|
|
180
|
+
printSectionId="print-section"
|
|
171
181
|
ngxPrint>print</button>
|
|
172
182
|
```
|
|
173
183
|
|
|
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
|
|
184
|
+
- 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
185
|
|
|
176
186
|
```html
|
|
177
187
|
<button (printCompleted)="onPrintComplete()"
|
|
@@ -182,66 +192,83 @@ Here some simple styles were added to every `h1` & `h2` tags within the `div` wh
|
|
|
182
192
|
|
|
183
193
|
## Using NgxPrint as a service (v1.5+)
|
|
184
194
|
|
|
185
|
-
Inject the NgxPrintService into your component or service:
|
|
195
|
+
Inject the `NgxPrintService` into your component or service:
|
|
186
196
|
|
|
187
197
|
```ts
|
|
198
|
+
import { inject } from '@angular/core';
|
|
199
|
+
import { NgxPrintService, PrintOptions } from 'ngx-print';
|
|
200
|
+
|
|
188
201
|
private readonly printService = inject(NgxPrintService);
|
|
189
202
|
```
|
|
190
203
|
|
|
191
204
|
### Printing a Section
|
|
192
205
|
|
|
193
|
-
```
|
|
194
|
-
import { PrintOptions } from '
|
|
206
|
+
```ts
|
|
207
|
+
import { PrintOptions } from 'ngx-print';
|
|
195
208
|
|
|
196
209
|
printMe(): void {
|
|
197
|
-
const customPrintOptions
|
|
198
|
-
|
|
199
|
-
|
|
210
|
+
const customPrintOptions = new PrintOptions({
|
|
211
|
+
printSectionId: 'print-section',
|
|
212
|
+
// add any other print options as needed
|
|
200
213
|
});
|
|
201
|
-
this.printService.print(customPrintOptions)
|
|
214
|
+
this.printService.print(customPrintOptions);
|
|
202
215
|
}
|
|
203
216
|
```
|
|
204
217
|
|
|
205
218
|
### Print Options Object
|
|
206
|
-
|
|
219
|
+
|
|
220
|
+
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:
|
|
221
|
+
|
|
207
222
|
```typescript
|
|
208
|
-
|
|
209
|
-
printTitle: string =
|
|
223
|
+
printSectionId: string = '';
|
|
224
|
+
printTitle: string = '';
|
|
210
225
|
useExistingCss: boolean = false;
|
|
211
226
|
bodyClass: string = '';
|
|
212
|
-
|
|
227
|
+
printMethod: 'window' | 'tab' | 'iframe' = 'window';
|
|
213
228
|
previewOnly: boolean = false;
|
|
214
229
|
closeWindow: boolean = true;
|
|
215
230
|
printDelay: number = 0;
|
|
216
231
|
```
|
|
217
232
|
|
|
233
|
+
| Property | Type | Default | Description |
|
|
234
|
+
| ---------------- | ------------------------------- | ---------- | ---------------------------------------------------------------------------- |
|
|
235
|
+
| `printSectionId` | `string` | `''` | **Required.** The `id` of the element to print. |
|
|
236
|
+
| `printTitle` | `string` | `''` | Title shown in the print document. |
|
|
237
|
+
| `useExistingCss` | `boolean` | `false` | Copies `<style>` and `<link>` tags from the host page. |
|
|
238
|
+
| `bodyClass` | `string` | `''` | CSS class(es) applied to the print `<body>`. |
|
|
239
|
+
| `printMethod` | `'window' \| 'tab' \| 'iframe'` | `'window'` | Controls how printing is triggered: popup window, new tab, or silent iframe. |
|
|
240
|
+
| `previewOnly` | `boolean` | `false` | Opens the print target without triggering the print dialog. |
|
|
241
|
+
| `closeWindow` | `boolean` | `true` | Closes the popup window after printing (ignored for `iframe`). |
|
|
242
|
+
| `printDelay` | `number` | `0` | Delay in milliseconds before the print dialog is opened. |
|
|
243
|
+
|
|
218
244
|
### Setting PrintStyles or StyleSheets
|
|
219
245
|
|
|
220
|
-
```
|
|
221
|
-
// Optional
|
|
246
|
+
```ts
|
|
247
|
+
// Optional: CSS as a key-value pair
|
|
222
248
|
this.printService.printStyle = styleSheet;
|
|
223
249
|
|
|
224
|
-
// Optional
|
|
250
|
+
// Optional: path to a CSS file
|
|
225
251
|
this.printService.styleSheetFile = fileLocation;
|
|
226
252
|
```
|
|
227
253
|
|
|
228
|
-
### Subscribing to print event
|
|
254
|
+
### Subscribing to the print event
|
|
229
255
|
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
256
|
+
```ts
|
|
257
|
+
this.printService.printComplete$.pipe(take(1)).subscribe(() => {
|
|
258
|
+
console.log('Print completed!');
|
|
259
|
+
});
|
|
234
260
|
```
|
|
235
261
|
|
|
236
262
|
## Content-Security-Policy (CSP) Support
|
|
237
|
-
|
|
263
|
+
|
|
264
|
+
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
265
|
|
|
239
266
|
## Contributors :1st_place_medal:
|
|
240
267
|
|
|
241
|
-
Huge thanks to: [deeplotia](https://github.com/deeplotia)
|
|
268
|
+
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
269
|
|
|
243
270
|
## Donation
|
|
244
271
|
|
|
245
|
-
Did this project help you
|
|
272
|
+
Did this project help you reduce time? I won't say no to a cup of coffee 🍵 :)
|
|
246
273
|
|
|
247
274
|
[](https://www.paypal.me/selemxmn/2)
|
package/fesm2022/ngx-print.mjs
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, CSP_NONCE, Injectable, output,
|
|
2
|
+
import { inject, DOCUMENT, CSP_NONCE, Injectable, output, Input, Directive, NgModule } from '@angular/core';
|
|
3
3
|
import { Subject, take } from 'rxjs';
|
|
4
4
|
|
|
5
|
+
class PrintOptions {
|
|
6
|
+
printSectionId = '';
|
|
7
|
+
printTitle = '';
|
|
8
|
+
useExistingCss = false;
|
|
9
|
+
bodyClass = '';
|
|
10
|
+
printMethod = 'window';
|
|
11
|
+
previewOnly = false;
|
|
12
|
+
closeWindow = true;
|
|
13
|
+
printDelay = 0;
|
|
14
|
+
constructor(options) {
|
|
15
|
+
if (options) {
|
|
16
|
+
Object.assign(this, options);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
5
21
|
class PrintBase {
|
|
22
|
+
document = inject(DOCUMENT);
|
|
6
23
|
nonce = inject(CSP_NONCE, { optional: true });
|
|
7
24
|
_iframeElement;
|
|
8
25
|
_printStyle = [];
|
|
@@ -47,81 +64,98 @@ class PrintBase {
|
|
|
47
64
|
* @param {string} cssList - CSS file or list of CSS files.
|
|
48
65
|
* @protected
|
|
49
66
|
*/
|
|
67
|
+
// prettier-ignore
|
|
50
68
|
setStyleSheetFile(cssList) {
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
this._styleSheetFile = valueArr.map(val => linkTagFn(val)).join('');
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
this._styleSheetFile = linkTagFn(cssList);
|
|
60
|
-
}
|
|
69
|
+
const files = cssList.split(',').map(f => f.trim());
|
|
70
|
+
const nonceAttr = this.nonce ? ` nonce="${this.nonce}"` : '';
|
|
71
|
+
this._styleSheetFile = files
|
|
72
|
+
.map(url => `<link${nonceAttr} rel="stylesheet" type="text/css" href="${url}">`)
|
|
73
|
+
.join('');
|
|
61
74
|
}
|
|
62
75
|
//#endregion
|
|
63
76
|
//#region Private methods used by PrintBase
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
77
|
+
syncFormValues(source, clone) {
|
|
78
|
+
// Select all form elements
|
|
79
|
+
const selector = 'input, select, textarea';
|
|
80
|
+
const sourceEls = source.querySelectorAll(selector);
|
|
81
|
+
const cloneEls = clone.querySelectorAll(selector);
|
|
82
|
+
for (let i = 0; i < sourceEls.length; i++) {
|
|
83
|
+
const srcNode = sourceEls[i];
|
|
84
|
+
const cloneNode = cloneEls[i];
|
|
85
|
+
if (srcNode instanceof HTMLInputElement) {
|
|
86
|
+
if (srcNode.type === 'checkbox' || srcNode.type === 'radio') {
|
|
87
|
+
if (srcNode.checked)
|
|
88
|
+
cloneNode.setAttribute('checked', '');
|
|
89
|
+
else
|
|
90
|
+
cloneNode.removeAttribute('checked'); // Remove if unchecked
|
|
91
|
+
}
|
|
92
|
+
else if (srcNode.type === 'file') {
|
|
93
|
+
// File inputs can't be set programmatically for security
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
cloneNode.setAttribute('value', srcNode.value);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else if (srcNode instanceof HTMLTextAreaElement) {
|
|
101
|
+
cloneNode.textContent = srcNode.value; // Use textContent, not innerHTML
|
|
102
|
+
}
|
|
103
|
+
else if (srcNode instanceof HTMLSelectElement) {
|
|
104
|
+
Array.from(cloneNode.options).forEach((opt, idx) => {
|
|
105
|
+
if (idx === srcNode.selectedIndex) {
|
|
106
|
+
opt.setAttribute('selected', '');
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
opt.removeAttribute('selected'); // Remove from non-selected
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
75
113
|
}
|
|
76
114
|
}
|
|
77
115
|
/**
|
|
78
|
-
*
|
|
116
|
+
* Converts a canvas element to an image and returns its HTML string.
|
|
79
117
|
*
|
|
80
|
-
* @param {
|
|
118
|
+
* @param {HTMLCanvasElement} canvasElm - The canvas element to convert.
|
|
119
|
+
* @returns {HTMLImageElement | null} - HTML Element of the image.
|
|
81
120
|
* @private
|
|
82
121
|
*/
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
122
|
+
canvasToImageHtml(canvasElm) {
|
|
123
|
+
try {
|
|
124
|
+
const dataUrl = canvasElm.toDataURL(); // may throw if canvas is tainted
|
|
125
|
+
const img = this.document.createElement('img');
|
|
126
|
+
img.src = dataUrl;
|
|
127
|
+
img.style.maxWidth = '100%';
|
|
128
|
+
// Preserve displayed size (not just bitmap size)
|
|
129
|
+
const rect = canvasElm.getBoundingClientRect();
|
|
130
|
+
if (rect.width)
|
|
131
|
+
img.style.width = `${rect.width}px`;
|
|
132
|
+
if (rect.height)
|
|
133
|
+
img.style.height = `${rect.height}px`;
|
|
134
|
+
return img;
|
|
90
135
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
* @param {HTMLCollectionOf<HTMLTextAreaElement>} elements - Collection of textarea elements.
|
|
96
|
-
* @private
|
|
97
|
-
*/
|
|
98
|
-
updateTextAreaDefaults(elements) {
|
|
99
|
-
for (const element of Array.from(elements)) {
|
|
100
|
-
element['defaultValue'] = element.value;
|
|
136
|
+
catch (err) {
|
|
137
|
+
console.warn(`Canvas conversion failed for ${canvasElm}. Likely the canvas is tainted:`, err);
|
|
138
|
+
// If toDataURL() fails (e.g., tainted canvas), keep canvas as-is in print output
|
|
139
|
+
return null;
|
|
101
140
|
}
|
|
102
141
|
}
|
|
103
|
-
/**
|
|
104
|
-
* Converts a canvas element to an image and returns its HTML string.
|
|
105
|
-
*
|
|
106
|
-
* @param {HTMLCanvasElement} element - The canvas element to convert.
|
|
107
|
-
* @returns {string} - HTML string of the image.
|
|
108
|
-
* @private
|
|
109
|
-
*/
|
|
110
|
-
canvasToImageHtml(element) {
|
|
111
|
-
const dataUrl = element.toDataURL();
|
|
112
|
-
return `<img src="${dataUrl}" style="max-width: 100%;">`;
|
|
113
|
-
}
|
|
114
142
|
/**
|
|
115
143
|
* Includes canvas contents in the print section via img tags.
|
|
116
144
|
*
|
|
117
|
-
* @param {HTMLCollectionOf<HTMLCanvasElement>} elements - Collection of canvas elements.
|
|
118
145
|
* @private
|
|
146
|
+
* @param source
|
|
147
|
+
* @param clone
|
|
119
148
|
*/
|
|
120
|
-
updateCanvasToImage(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
149
|
+
updateCanvasToImage(source, clone) {
|
|
150
|
+
const sourceCanvases = source.querySelectorAll('canvas');
|
|
151
|
+
const cloneCanvases = clone.querySelectorAll('canvas');
|
|
152
|
+
for (let i = 0; i < sourceCanvases.length; i++) {
|
|
153
|
+
const srcCanvas = sourceCanvases[i];
|
|
154
|
+
const cloneCanvas = cloneCanvases[i];
|
|
155
|
+
const img = this.canvasToImageHtml(srcCanvas);
|
|
156
|
+
if (img) {
|
|
157
|
+
cloneCanvas.replaceWith(img);
|
|
158
|
+
}
|
|
125
159
|
}
|
|
126
160
|
}
|
|
127
161
|
/**
|
|
@@ -132,18 +166,13 @@ class PrintBase {
|
|
|
132
166
|
* @private
|
|
133
167
|
*/
|
|
134
168
|
getHtmlContents(printSectionId) {
|
|
135
|
-
const
|
|
136
|
-
if (!
|
|
169
|
+
const sourceElm = this.document.getElementById(printSectionId);
|
|
170
|
+
if (!sourceElm)
|
|
137
171
|
return null;
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
this.updateInputDefaults(inputEls);
|
|
143
|
-
this.updateSelectDefaults(selectEls);
|
|
144
|
-
this.updateTextAreaDefaults(textAreaEls);
|
|
145
|
-
this.updateCanvasToImage(canvasEls);
|
|
146
|
-
return printContents.innerHTML;
|
|
172
|
+
const cloneElm = sourceElm.cloneNode(true); // cloneNode(true) deep clones subtree
|
|
173
|
+
this.syncFormValues(sourceElm, cloneElm);
|
|
174
|
+
this.updateCanvasToImage(sourceElm, cloneElm);
|
|
175
|
+
return cloneElm.innerHTML;
|
|
147
176
|
}
|
|
148
177
|
/**
|
|
149
178
|
* Retrieves the HTML content of elements with the specified tag.
|
|
@@ -154,9 +183,9 @@ class PrintBase {
|
|
|
154
183
|
*/
|
|
155
184
|
getElementTag(tag) {
|
|
156
185
|
const html = [];
|
|
157
|
-
const elements = document.getElementsByTagName(tag);
|
|
158
|
-
for (
|
|
159
|
-
html.push(
|
|
186
|
+
const elements = this.document.getElementsByTagName(tag);
|
|
187
|
+
for (const el of Array.from(elements)) {
|
|
188
|
+
html.push(el.outerHTML);
|
|
160
189
|
}
|
|
161
190
|
return html.join('\r\n');
|
|
162
191
|
}
|
|
@@ -167,10 +196,11 @@ class PrintBase {
|
|
|
167
196
|
/**
|
|
168
197
|
* Prints the specified content using the provided print options.
|
|
169
198
|
*
|
|
170
|
-
* @param {PrintOptions} printOptions - Options for printing.
|
|
171
199
|
* @public
|
|
200
|
+
* @param printOptionInput - Options for printing.
|
|
172
201
|
*/
|
|
173
|
-
print(
|
|
202
|
+
print(printOptionInput) {
|
|
203
|
+
const printOptions = new PrintOptions(printOptionInput);
|
|
174
204
|
if (printOptions.printMethod === 'iframe') {
|
|
175
205
|
this.printWithIframe(printOptions);
|
|
176
206
|
}
|
|
@@ -213,7 +243,7 @@ class PrintBase {
|
|
|
213
243
|
if (this._iframeElement) {
|
|
214
244
|
this._iframeElement.remove();
|
|
215
245
|
}
|
|
216
|
-
this._iframeElement = document.createElement('iframe');
|
|
246
|
+
this._iframeElement = this.document.createElement('iframe');
|
|
217
247
|
const iframe = this._iframeElement;
|
|
218
248
|
iframe.id = 'print-iframe-' + new Date().getTime();
|
|
219
249
|
iframe.style.position = 'absolute';
|
|
@@ -221,18 +251,19 @@ class PrintBase {
|
|
|
221
251
|
iframe.style.top = '-9999px';
|
|
222
252
|
iframe.style.width = '0px';
|
|
223
253
|
iframe.style.height = '0px';
|
|
224
|
-
|
|
254
|
+
iframe.ariaHidden = 'true';
|
|
255
|
+
this.document.body.appendChild(iframe);
|
|
225
256
|
const iframeDoc = iframe.contentDocument || iframe.contentWindow?.document;
|
|
226
257
|
if (!iframeDoc) {
|
|
227
258
|
console.error('Could not access iframe document.');
|
|
228
|
-
document.body.removeChild(iframe);
|
|
259
|
+
this.document.body.removeChild(iframe);
|
|
229
260
|
return;
|
|
230
261
|
}
|
|
231
262
|
iframeDoc.open();
|
|
232
263
|
const success = this.buildPrintDocument(iframeDoc, printOptions);
|
|
233
264
|
if (!success) {
|
|
234
265
|
iframeDoc.close();
|
|
235
|
-
document.body.removeChild(iframe);
|
|
266
|
+
this.document.body.removeChild(iframe);
|
|
236
267
|
return;
|
|
237
268
|
}
|
|
238
269
|
iframeDoc.close();
|
|
@@ -240,7 +271,7 @@ class PrintBase {
|
|
|
240
271
|
const printWindow = iframe.contentWindow;
|
|
241
272
|
if (!printWindow) {
|
|
242
273
|
console.error('Could not access iframe window.');
|
|
243
|
-
document.body.removeChild(iframe);
|
|
274
|
+
this.document.body.removeChild(iframe);
|
|
244
275
|
return;
|
|
245
276
|
}
|
|
246
277
|
setTimeout(() => {
|
|
@@ -274,7 +305,7 @@ class PrintBase {
|
|
|
274
305
|
buildPrintDocument(doc, printOptions) {
|
|
275
306
|
const components = this.prepareDocumentComponents(printOptions);
|
|
276
307
|
if (!components.printContents) {
|
|
277
|
-
console.error(`Print section with id ${printOptions.printSectionId} not found.`);
|
|
308
|
+
console.error(`Print section with id "${printOptions.printSectionId}" not found.`);
|
|
278
309
|
return false;
|
|
279
310
|
}
|
|
280
311
|
const html = doc.createElement('html');
|
|
@@ -285,8 +316,9 @@ class PrintBase {
|
|
|
285
316
|
title.textContent = printOptions.printTitle || '';
|
|
286
317
|
head.appendChild(title);
|
|
287
318
|
// Add all head content
|
|
288
|
-
if (components.baseTag)
|
|
319
|
+
if (components.baseTag) {
|
|
289
320
|
head.innerHTML += components.baseTag;
|
|
321
|
+
}
|
|
290
322
|
head.innerHTML += this.returnStyleValues();
|
|
291
323
|
head.innerHTML += this.returnStyleSheetLinkTags();
|
|
292
324
|
head.innerHTML += components.styles;
|
|
@@ -301,32 +333,16 @@ class PrintBase {
|
|
|
301
333
|
doc.appendChild(html);
|
|
302
334
|
return true;
|
|
303
335
|
}
|
|
304
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
305
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
336
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: PrintBase, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
337
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: PrintBase, providedIn: 'root' });
|
|
306
338
|
}
|
|
307
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
339
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: PrintBase, decorators: [{
|
|
308
340
|
type: Injectable,
|
|
309
341
|
args: [{
|
|
310
342
|
providedIn: 'root',
|
|
311
343
|
}]
|
|
312
344
|
}] });
|
|
313
345
|
|
|
314
|
-
class PrintOptions {
|
|
315
|
-
printSectionId = '';
|
|
316
|
-
printTitle = '';
|
|
317
|
-
useExistingCss = false;
|
|
318
|
-
bodyClass = '';
|
|
319
|
-
printMethod = 'window';
|
|
320
|
-
previewOnly = false;
|
|
321
|
-
closeWindow = true;
|
|
322
|
-
printDelay = 0;
|
|
323
|
-
constructor(options) {
|
|
324
|
-
if (options) {
|
|
325
|
-
Object.assign(this, options);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
346
|
class NgxPrintDirective extends PrintBase {
|
|
331
347
|
printOptions = new PrintOptions();
|
|
332
348
|
/**
|
|
@@ -413,18 +429,21 @@ class NgxPrintDirective extends PrintBase {
|
|
|
413
429
|
print() {
|
|
414
430
|
super.print(this.printOptions);
|
|
415
431
|
this.printComplete.pipe(take(1)).subscribe(() => {
|
|
416
|
-
this.printCompleted.emit(
|
|
432
|
+
this.printCompleted.emit();
|
|
417
433
|
});
|
|
418
434
|
}
|
|
419
435
|
printCompleted = output();
|
|
420
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
421
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
436
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: NgxPrintDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
437
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.2", type: NgxPrintDirective, isStandalone: true, selector: "[ngxPrint]", inputs: { previewOnly: "previewOnly", printSectionId: "printSectionId", printTitle: "printTitle", useExistingCss: "useExistingCss", printDelay: "printDelay", closeWindow: "closeWindow", bodyClass: "bodyClass", printMethod: "printMethod", printStyle: "printStyle", styleSheetFile: "styleSheetFile" }, outputs: { printCompleted: "printCompleted" }, host: { listeners: { "click": "print()" } }, usesInheritance: true, ngImport: i0 });
|
|
422
438
|
}
|
|
423
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
439
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: NgxPrintDirective, decorators: [{
|
|
424
440
|
type: Directive,
|
|
425
441
|
args: [{
|
|
426
442
|
selector: '[ngxPrint]',
|
|
427
443
|
standalone: true,
|
|
444
|
+
host: {
|
|
445
|
+
'(click)': 'print()',
|
|
446
|
+
},
|
|
428
447
|
}]
|
|
429
448
|
}], propDecorators: { previewOnly: [{
|
|
430
449
|
type: Input
|
|
@@ -446,17 +465,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImpor
|
|
|
446
465
|
type: Input
|
|
447
466
|
}], styleSheetFile: [{
|
|
448
467
|
type: Input
|
|
449
|
-
}], print: [{
|
|
450
|
-
type: HostListener,
|
|
451
|
-
args: ['click']
|
|
452
468
|
}], printCompleted: [{ type: i0.Output, args: ["printCompleted"] }] } });
|
|
453
469
|
|
|
454
470
|
class NgxPrintModule {
|
|
455
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
456
|
-
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
|
|
457
|
-
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
471
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: NgxPrintModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
472
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.0.2", ngImport: i0, type: NgxPrintModule, imports: [NgxPrintDirective], exports: [NgxPrintDirective] });
|
|
473
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: NgxPrintModule });
|
|
458
474
|
}
|
|
459
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
475
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: NgxPrintModule, decorators: [{
|
|
460
476
|
type: NgModule,
|
|
461
477
|
args: [{
|
|
462
478
|
imports: [NgxPrintDirective],
|
|
@@ -505,10 +521,10 @@ class NgxPrintService extends PrintBase {
|
|
|
505
521
|
set styleSheetFile(cssList) {
|
|
506
522
|
super.setStyleSheetFile(cssList);
|
|
507
523
|
}
|
|
508
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
509
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
524
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: NgxPrintService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
525
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: NgxPrintService, providedIn: 'root' });
|
|
510
526
|
}
|
|
511
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
527
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: NgxPrintService, decorators: [{
|
|
512
528
|
type: Injectable,
|
|
513
529
|
args: [{
|
|
514
530
|
providedIn: 'root',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngx-print.mjs","sources":["../../../src/lib/ngx-print.base.ts","../../../src/lib/print-options.ts","../../../src/lib/ngx-print.directive.ts","../../../src/lib/ngx-print.module.ts","../../../src/lib/ngx-print.service.ts","../../../src/public_api.ts","../../../src/ngx-print.ts"],"sourcesContent":["import { CSP_NONCE, inject, Injectable } from '@angular/core';\r\nimport { Subject } from 'rxjs';\r\nimport { PrintOptions } from './print-options';\r\n\r\n@Injectable({\r\n providedIn: 'root',\r\n})\r\nexport class PrintBase {\r\n private nonce = inject(CSP_NONCE, { optional: true });\r\n\r\n private _iframeElement: HTMLIFrameElement | undefined;\r\n private _printStyle: string[] = [];\r\n private _styleSheetFile: string = '';\r\n protected printComplete = new Subject<void>();\r\n\r\n //#region Getters and Setters\r\n /**\r\n * Sets the print styles based on the provided values.\r\n *\r\n * @param {Object} values - Key-value pairs representing print styles.\r\n * @protected\r\n */\r\n protected setPrintStyle(values: { [key: string]: { [key: string]: string } }) {\r\n this._printStyle = [];\r\n for (const key of Object.keys(values)) {\r\n this._printStyle.push((key + JSON.stringify(values[key])).replace(/['\"]+/g, ''));\r\n }\r\n }\r\n\r\n /**\r\n *\r\n *\r\n * @returns the string that create the stylesheet which will be injected\r\n * later within <style></style> tag.\r\n *\r\n * -join/replace to transform an array objects to css-styled string\r\n */\r\n public returnStyleValues() {\r\n const styleNonce = this.nonce ? ` nonce=\"${this.nonce}\"` : '';\r\n return `<style${styleNonce}> ${this._printStyle.join(' ').replace(/,/g, ';')} </style>`;\r\n }\r\n\r\n /**\r\n * @returns string which contains the link tags containing the css which will\r\n * be injected later within <head></head> tag.\r\n *\r\n */\r\n private returnStyleSheetLinkTags() {\r\n return this._styleSheetFile;\r\n }\r\n\r\n /**\r\n * Sets the style sheet file based on the provided CSS list.\r\n *\r\n * @param {string} cssList - CSS file or list of CSS files.\r\n * @protected\r\n */\r\n protected setStyleSheetFile(cssList: string) {\r\n const linkTagFn = (cssFileName: string) => {\r\n return `<link rel=\"stylesheet\" type=\"text/css\" href=\"${cssFileName}\">`;\r\n };\r\n\r\n if (cssList.indexOf(',') !== -1) {\r\n const valueArr = cssList.split(',');\r\n this._styleSheetFile = valueArr.map(val => linkTagFn(val)).join('');\r\n } else {\r\n this._styleSheetFile = linkTagFn(cssList);\r\n }\r\n }\r\n\r\n //#endregion\r\n\r\n //#region Private methods used by PrintBase\r\n\r\n /**\r\n * Updates the default values for input elements.\r\n *\r\n * @param {HTMLCollectionOf<HTMLInputElement>} elements - Collection of input elements.\r\n * @private\r\n */\r\n private updateInputDefaults(elements: HTMLCollectionOf<HTMLInputElement>): void {\r\n for (const element of Array.from(elements)) {\r\n element['defaultValue'] = element.value;\r\n if (element['checked']) element['defaultChecked'] = true;\r\n }\r\n }\r\n\r\n /**\r\n * Updates the default values for select elements.\r\n *\r\n * @param {HTMLCollectionOf<HTMLSelectElement>} elements - Collection of select elements.\r\n * @private\r\n */\r\n private updateSelectDefaults(elements: HTMLCollectionOf<HTMLSelectElement>): void {\r\n for (const element of Array.from(elements)) {\r\n const selectedIdx = element.selectedIndex;\r\n if (selectedIdx < 0 || selectedIdx >= element.options.length) continue;\r\n const selectedOption: HTMLOptionElement = element.options[selectedIdx];\r\n\r\n selectedOption.defaultSelected = true;\r\n }\r\n }\r\n\r\n /**\r\n * Updates the default values for textarea elements.\r\n *\r\n * @param {HTMLCollectionOf<HTMLTextAreaElement>} elements - Collection of textarea elements.\r\n * @private\r\n */\r\n private updateTextAreaDefaults(elements: HTMLCollectionOf<HTMLTextAreaElement>): void {\r\n for (const element of Array.from(elements)) {\r\n element['defaultValue'] = element.value;\r\n }\r\n }\r\n\r\n /**\r\n * Converts a canvas element to an image and returns its HTML string.\r\n *\r\n * @param {HTMLCanvasElement} element - The canvas element to convert.\r\n * @returns {string} - HTML string of the image.\r\n * @private\r\n */\r\n private canvasToImageHtml(element: HTMLCanvasElement): string {\r\n const dataUrl = element.toDataURL();\r\n return `<img src=\"${dataUrl}\" style=\"max-width: 100%;\">`;\r\n }\r\n\r\n /**\r\n * Includes canvas contents in the print section via img tags.\r\n *\r\n * @param {HTMLCollectionOf<HTMLCanvasElement>} elements - Collection of canvas elements.\r\n * @private\r\n */\r\n private updateCanvasToImage(elements: HTMLCollectionOf<HTMLCanvasElement>): void {\r\n for (const canvasElement of Array.from(elements)) {\r\n const imgHtml = this.canvasToImageHtml(canvasElement);\r\n canvasElement.insertAdjacentHTML('afterend', imgHtml);\r\n canvasElement.remove();\r\n }\r\n }\r\n\r\n /**\r\n * Retrieves the HTML content of a specified printing section.\r\n *\r\n * @param {string} printSectionId - Id of the printing section.\r\n * @returns {string | null} - HTML content of the printing section, or null if not found.\r\n * @private\r\n */\r\n private getHtmlContents(printSectionId: string): string | null {\r\n const printContents = document.getElementById(printSectionId);\r\n if (!printContents) return null;\r\n\r\n const inputEls = printContents.getElementsByTagName('input');\r\n const selectEls = printContents.getElementsByTagName('select');\r\n const textAreaEls = printContents.getElementsByTagName('textarea');\r\n const canvasEls = printContents.getElementsByTagName('canvas');\r\n\r\n this.updateInputDefaults(inputEls);\r\n this.updateSelectDefaults(selectEls);\r\n this.updateTextAreaDefaults(textAreaEls);\r\n this.updateCanvasToImage(canvasEls);\r\n\r\n return printContents.innerHTML;\r\n }\r\n\r\n /**\r\n * Retrieves the HTML content of elements with the specified tag.\r\n *\r\n * @param {keyof HTMLElementTagNameMap} tag - HTML tag name.\r\n * @returns {string} - Concatenated outerHTML of elements with the specified tag.\r\n * @private\r\n */\r\n private getElementTag(tag: keyof HTMLElementTagNameMap): string {\r\n const html: string[] = [];\r\n const elements = document.getElementsByTagName(tag);\r\n for (let index = 0; index < elements.length; index++) {\r\n html.push(elements[index].outerHTML);\r\n }\r\n return html.join('\\r\\n');\r\n }\r\n\r\n //#endregion\r\n\r\n protected notifyPrintComplete() {\r\n this.printComplete.next();\r\n }\r\n\r\n /**\r\n * Prints the specified content using the provided print options.\r\n *\r\n * @param {PrintOptions} printOptions - Options for printing.\r\n * @public\r\n */\r\n protected print(printOptions: PrintOptions): void {\r\n if (printOptions.printMethod === 'iframe') {\r\n this.printWithIframe(printOptions);\r\n } else {\r\n this.printWithWindow(printOptions);\r\n }\r\n }\r\n\r\n protected printWithWindow(printOptions: PrintOptions) {\r\n // If the openNewTab option is set to true, then set the popOut option to an empty string\r\n // This will cause the print dialog to open in a new tab.\r\n const popOut = printOptions.printMethod === 'tab' ? '' : 'top=0,left=0,height=auto,width=auto';\r\n\r\n const popupWin = window.open('', '_blank', popOut);\r\n\r\n if (!popupWin) {\r\n // the popup window could not be opened.\r\n console.error('Could not open print window.');\r\n return;\r\n }\r\n\r\n popupWin.document.open();\r\n // Create the HTML structure\r\n this.buildPrintDocument(popupWin.document, printOptions);\r\n\r\n popupWin.document.close();\r\n\r\n // Listen for the window closing\r\n const checkClosedInterval = setInterval(() => {\r\n if (popupWin.closed) {\r\n clearInterval(checkClosedInterval);\r\n this.notifyPrintComplete();\r\n }\r\n }, 500);\r\n\r\n popupWin.addEventListener('load', () => {\r\n if (!printOptions.previewOnly) {\r\n setTimeout(() => {\r\n popupWin.print();\r\n if (printOptions.closeWindow) popupWin.close();\r\n }, printOptions.printDelay || 0);\r\n }\r\n });\r\n }\r\n\r\n private printWithIframe(printOptions: PrintOptions): void {\r\n if (this._iframeElement) {\r\n this._iframeElement.remove();\r\n }\r\n this._iframeElement = document.createElement('iframe');\r\n const iframe = this._iframeElement;\r\n iframe.id = 'print-iframe-' + new Date().getTime();\r\n iframe.style.position = 'absolute';\r\n iframe.style.left = '-9999px';\r\n iframe.style.top = '-9999px';\r\n iframe.style.width = '0px';\r\n iframe.style.height = '0px';\r\n\r\n document.body.appendChild(iframe);\r\n\r\n const iframeDoc = iframe.contentDocument || iframe.contentWindow?.document;\r\n if (!iframeDoc) {\r\n console.error('Could not access iframe document.');\r\n document.body.removeChild(iframe);\r\n return;\r\n }\r\n\r\n iframeDoc.open();\r\n const success = this.buildPrintDocument(iframeDoc, printOptions);\r\n if (!success) {\r\n iframeDoc.close();\r\n document.body.removeChild(iframe);\r\n return;\r\n }\r\n iframeDoc.close();\r\n\r\n iframe.onload = () => {\r\n const printWindow = iframe.contentWindow;\r\n if (!printWindow) {\r\n console.error('Could not access iframe window.');\r\n document.body.removeChild(iframe);\r\n return;\r\n }\r\n\r\n setTimeout(() => {\r\n if (printOptions.previewOnly) {\r\n return;\r\n }\r\n printWindow.focus();\r\n printWindow.print();\r\n\r\n const mediaQueryList = printWindow.matchMedia('print');\r\n const listener = (mql: MediaQueryListEvent | MediaQueryList) => {\r\n if (!mql.matches) {\r\n this.notifyPrintComplete();\r\n mediaQueryList.removeEventListener('change', listener);\r\n }\r\n };\r\n\r\n mediaQueryList.addEventListener('change', listener);\r\n }, printOptions.printDelay || 0);\r\n };\r\n }\r\n\r\n private prepareDocumentComponents(printOptions: PrintOptions) {\r\n let styles = '';\r\n let links = '';\r\n const baseTag = this.getElementTag('base');\r\n\r\n if (printOptions.useExistingCss) {\r\n styles = this.getElementTag('style');\r\n links = this.getElementTag('link');\r\n }\r\n\r\n const printContents = this.getHtmlContents(printOptions.printSectionId);\r\n\r\n return { styles, links, baseTag, printContents };\r\n }\r\n\r\n private buildPrintDocument(doc: Document, printOptions: PrintOptions): boolean {\r\n const components = this.prepareDocumentComponents(printOptions);\r\n\r\n if (!components.printContents) {\r\n console.error(`Print section with id ${printOptions.printSectionId} not found.`);\r\n return false;\r\n }\r\n\r\n const html = doc.createElement('html');\r\n const head = doc.createElement('head');\r\n const body = doc.createElement('body');\r\n\r\n // Set title\r\n const title = doc.createElement('title');\r\n title.textContent = printOptions.printTitle || '';\r\n head.appendChild(title);\r\n\r\n // Add all head content\r\n if (components.baseTag) head.innerHTML += components.baseTag;\r\n head.innerHTML += this.returnStyleValues();\r\n head.innerHTML += this.returnStyleSheetLinkTags();\r\n head.innerHTML += components.styles;\r\n head.innerHTML += components.links;\r\n\r\n // Set body class and content\r\n if (printOptions.bodyClass) body.className = printOptions.bodyClass;\r\n body.innerHTML += components.printContents;\r\n\r\n // Assemble document\r\n html.appendChild(head);\r\n html.appendChild(body);\r\n doc.appendChild(html);\r\n\r\n return true;\r\n }\r\n}\r\n","export class PrintOptions {\r\n printSectionId: string = '';\r\n printTitle: string = '';\r\n useExistingCss: boolean = false;\r\n bodyClass: string = '';\r\n printMethod: 'window' | 'tab' | 'iframe' = 'window';\r\n previewOnly: boolean = false;\r\n closeWindow: boolean = true;\r\n printDelay: number = 0;\r\n\r\n constructor(options?: Partial<PrintOptions>) {\r\n if (options) {\r\n Object.assign(this, options);\r\n }\r\n }\r\n}\r\n","import { Directive, HostListener, Input, output } from '@angular/core';\r\nimport { PrintBase } from './ngx-print.base';\r\nimport { PrintOptions } from './print-options';\r\nimport { take } from 'rxjs';\r\n\r\n@Directive({\r\n selector: '[ngxPrint]',\r\n standalone: true,\r\n})\r\nexport class NgxPrintDirective extends PrintBase {\r\n private printOptions = new PrintOptions();\r\n\r\n /**\r\n * Prevents the print dialog from opening on the window\r\n *\r\n * @memberof NgxPrintDirective\r\n */\r\n @Input() set previewOnly(value: boolean) {\r\n this.printOptions = { ...this.printOptions, previewOnly: value };\r\n }\r\n\r\n /**\r\n *\r\n *\r\n * @memberof NgxPrintDirective\r\n */\r\n @Input() set printSectionId(value: string) {\r\n this.printOptions = { ...this.printOptions, printSectionId: value };\r\n }\r\n\r\n /**\r\n *\r\n *\r\n * @memberof NgxPrintDirective\r\n */\r\n @Input() set printTitle(value: string) {\r\n this.printOptions = { ...this.printOptions, printTitle: value };\r\n }\r\n\r\n /**\r\n *\r\n *\r\n * @memberof NgxPrintDirective\r\n */\r\n @Input() set useExistingCss(value: boolean) {\r\n this.printOptions = { ...this.printOptions, useExistingCss: value };\r\n }\r\n\r\n /**\r\n * A delay in milliseconds to force the print dialog to wait before opened. Default: 0\r\n *\r\n * @memberof NgxPrintDirective\r\n */\r\n @Input() set printDelay(value: number) {\r\n this.printOptions = { ...this.printOptions, printDelay: value };\r\n }\r\n\r\n /**\r\n * Whether to close the window after print() returns.\r\n *\r\n */\r\n @Input() set closeWindow(value: boolean) {\r\n this.printOptions = { ...this.printOptions, closeWindow: value };\r\n }\r\n\r\n /**\r\n * Class attribute to apply to the body element.\r\n *\r\n */\r\n @Input() set bodyClass(value: string) {\r\n this.printOptions = { ...this.printOptions, bodyClass: value };\r\n }\r\n\r\n /**\r\n * Which PrintMethod (iframe/window/tab) to use.\r\n *\r\n */\r\n @Input() set printMethod(value: typeof PrintOptions.prototype.printMethod) {\r\n this.printOptions = { ...this.printOptions, printMethod: value };\r\n }\r\n\r\n /**\r\n *\r\n *\r\n * @memberof NgxPrintDirective\r\n */\r\n @Input()\r\n set printStyle(values: { [key: string]: { [key: string]: string } }) {\r\n super.setPrintStyle(values);\r\n }\r\n\r\n /**\r\n * @memberof NgxPrintDirective\r\n * @param cssList\r\n */\r\n @Input()\r\n set styleSheetFile(cssList: string) {\r\n super.setStyleSheetFile(cssList);\r\n }\r\n\r\n /**\r\n *\r\n *\r\n * @memberof NgxPrintDirective\r\n */\r\n @HostListener('click')\r\n public override print(): void {\r\n super.print(this.printOptions);\r\n this.printComplete.pipe(take(1)).subscribe(() => {\r\n this.printCompleted.emit(undefined);\r\n });\r\n }\r\n\r\n readonly printCompleted = output<void>();\r\n}\r\n","import { NgModule } from '@angular/core';\r\nimport { NgxPrintDirective } from './ngx-print.directive';\r\n\r\n@NgModule({\r\n imports: [NgxPrintDirective],\r\n exports: [NgxPrintDirective],\r\n})\r\nexport class NgxPrintModule {}\r\n","import { Injectable } from '@angular/core';\r\nimport { PrintBase } from './ngx-print.base';\r\nimport { PrintOptions } from './print-options';\r\n\r\n/**\r\n * Service for handling printing functionality in Angular applications.\r\n * Extends the base printing class (PrintBase).\r\n *\r\n * @export\r\n * @class NgxPrintService\r\n * @extends {PrintBase}\r\n */\r\n@Injectable({\r\n providedIn: 'root',\r\n})\r\nexport class NgxPrintService extends PrintBase {\r\n printComplete$ = this.printComplete.asObservable();\r\n\r\n /**\r\n * Initiates the printing process using the provided print options.\r\n *\r\n * @param {PrintOptions} printOptions - Options for configuring the printing process.\r\n * @memberof NgxPrintService\r\n * @returns {void}\r\n */\r\n public override print(printOptions: PrintOptions): void {\r\n // Call the print method in the parent class\r\n super.print(printOptions);\r\n }\r\n\r\n /**\r\n * Sets the print style for the printing process.\r\n *\r\n * @param {{ [key: string]: { [key: string]: string } }} values - A dictionary representing the print styles.\r\n * @memberof NgxPrintService\r\n * @setter\r\n */\r\n set printStyle(values: { [key: string]: { [key: string]: string } }) {\r\n super.setPrintStyle(values);\r\n }\r\n\r\n /**\r\n * Sets the stylesheet file for the printing process.\r\n *\r\n * @param {string} cssList - A string representing the path to the stylesheet file.\r\n * @memberof NgxPrintService\r\n * @setter\r\n */\r\n set styleSheetFile(cssList: string) {\r\n super.setStyleSheetFile(cssList);\r\n }\r\n}\r\n","/*\r\n * Public API Surface of ngx-print\r\n */\r\nexport { NgxPrintDirective } from './lib/ngx-print.directive';\r\nexport { NgxPrintModule } from './lib/ngx-print.module';\r\nexport { NgxPrintService } from './lib/ngx-print.service';\r\nexport { PrintOptions } from './lib/print-options';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;MAOa,SAAS,CAAA;IACZ,KAAK,GAAG,MAAM,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAE7C,IAAA,cAAc;IACd,WAAW,GAAa,EAAE;IAC1B,eAAe,GAAW,EAAE;AAC1B,IAAA,aAAa,GAAG,IAAI,OAAO,EAAQ;;AAG7C;;;;;AAKG;AACO,IAAA,aAAa,CAAC,MAAoD,EAAA;AAC1E,QAAA,IAAI,CAAC,WAAW,GAAG,EAAE;QACrB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;YACrC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAClF;IACF;AAEA;;;;;;;AAOG;IACI,iBAAiB,GAAA;AACtB,QAAA,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,GAAG,CAAA,QAAA,EAAW,IAAI,CAAC,KAAK,CAAA,CAAA,CAAG,GAAG,EAAE;AAC7D,QAAA,OAAO,SAAS,UAAU,CAAA,EAAA,EA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AAMG;IACH,IAAI,UAAU,CAAC,MAAoD,EAAA;AACjE,QAAA,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC;IAC7B;AAEA;;;;;;AAMG;IACH,IAAI,cAAc,CAAC,OAAe,EAAA;AAChC,QAAA,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC;IAClC;uGAnCW,eAAe,EAAA,IAAA,EAAA,IAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAf,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,eAAe,cAFd,MAAM,EAAA,CAAA;;2FAEP,eAAe,EAAA,UAAA,EAAA,CAAA;kBAH3B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;ACdD;;AAEG;;ACFH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ngx-print.mjs","sources":["../../../src/lib/print-options.ts","../../../src/lib/ngx-print.base.ts","../../../src/lib/ngx-print.directive.ts","../../../src/lib/ngx-print.module.ts","../../../src/lib/ngx-print.service.ts","../../../src/public_api.ts","../../../src/ngx-print.ts"],"sourcesContent":["export class PrintOptions {\r\n printSectionId = '';\r\n printTitle = '';\r\n useExistingCss = false;\r\n bodyClass = '';\r\n printMethod: 'window' | 'tab' | 'iframe' = 'window';\r\n previewOnly = false;\r\n closeWindow = true;\r\n printDelay = 0;\r\n\r\n constructor(options?: Partial<PrintOptions>) {\r\n if (options) {\r\n Object.assign(this, options);\r\n }\r\n }\r\n}\r\n","import { CSP_NONCE, DOCUMENT, inject, Injectable } from '@angular/core';\r\nimport { Subject } from 'rxjs';\r\nimport { PrintOptions } from './print-options';\r\n\r\n/** For example:\r\n * {\r\n * 'h2': { 'border': 'solid 1px' },\r\n * 'h1': { 'color': 'red', 'border': '1px solid' },\r\n * */\r\nexport type PrintStyle = Record<string, Record<string, string>>;\r\n\r\n@Injectable({\r\n providedIn: 'root',\r\n})\r\nexport class PrintBase {\r\n private document = inject(DOCUMENT);\r\n private nonce = inject(CSP_NONCE, { optional: true });\r\n\r\n private _iframeElement: HTMLIFrameElement | undefined;\r\n private _printStyle: string[] = [];\r\n private _styleSheetFile = '';\r\n protected printComplete = new Subject<void>();\r\n\r\n //#region Getters and Setters\r\n /**\r\n * Sets the print styles based on the provided values.\r\n *\r\n * @param {Object} values - Key-value pairs representing print styles.\r\n * @protected\r\n */\r\n protected setPrintStyle(values: PrintStyle) {\r\n this._printStyle = [];\r\n for (const key of Object.keys(values)) {\r\n this._printStyle.push((key + JSON.stringify(values[key])).replace(/['\"]+/g, ''));\r\n }\r\n }\r\n\r\n /**\r\n *\r\n *\r\n * @returns the string that create the stylesheet which will be injected\r\n * later within <style></style> tag.\r\n *\r\n * -join/replace to transform an array objects to css-styled string\r\n */\r\n public returnStyleValues(): string {\r\n const styleNonce = this.nonce ? ` nonce=\"${this.nonce}\"` : '';\r\n return `<style${styleNonce}> ${this._printStyle.join(' ').replace(/,/g, ';')} </style>`;\r\n }\r\n\r\n /**\r\n * @returns string which contains the link tags containing the css which will\r\n * be injected later within <head></head> tag.\r\n *\r\n */\r\n private returnStyleSheetLinkTags(): string {\r\n return this._styleSheetFile;\r\n }\r\n\r\n /**\r\n * Sets the style sheet file based on the provided CSS list.\r\n *\r\n * @param {string} cssList - CSS file or list of CSS files.\r\n * @protected\r\n */\r\n // prettier-ignore\r\n protected setStyleSheetFile(cssList: string): void {\r\n const files = cssList.split(',').map(f => f.trim());\r\n const nonceAttr = this.nonce ? ` nonce=\"${this.nonce}\"` : '';\r\n this._styleSheetFile = files\r\n .map(url => `<link${nonceAttr} rel=\"stylesheet\" type=\"text/css\" href=\"${url}\">`)\r\n .join('');\r\n }\r\n\r\n //#endregion\r\n\r\n //#region Private methods used by PrintBase\r\n\r\n private syncFormValues(source: HTMLElement, clone: HTMLElement): void {\r\n // Select all form elements\r\n const selector = 'input, select, textarea';\r\n const sourceEls = source.querySelectorAll(selector);\r\n const cloneEls = clone.querySelectorAll(selector);\r\n\r\n for (let i = 0; i < sourceEls.length; i++) {\r\n const srcNode = sourceEls[i] as HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;\r\n const cloneNode = cloneEls[i] as typeof srcNode;\r\n\r\n if (srcNode instanceof HTMLInputElement) {\r\n if (srcNode.type === 'checkbox' || srcNode.type === 'radio') {\r\n if (srcNode.checked) cloneNode.setAttribute('checked', '');\r\n else cloneNode.removeAttribute('checked'); // Remove if unchecked\r\n } else if (srcNode.type === 'file') {\r\n // File inputs can't be set programmatically for security\r\n continue;\r\n } else {\r\n cloneNode.setAttribute('value', srcNode.value);\r\n }\r\n } else if (srcNode instanceof HTMLTextAreaElement) {\r\n cloneNode.textContent = srcNode.value; // Use textContent, not innerHTML\r\n } else if (srcNode instanceof HTMLSelectElement) {\r\n Array.from((cloneNode as HTMLSelectElement).options).forEach((opt, idx) => {\r\n if (idx === srcNode.selectedIndex) {\r\n opt.setAttribute('selected', '');\r\n } else {\r\n opt.removeAttribute('selected'); // Remove from non-selected\r\n }\r\n });\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Converts a canvas element to an image and returns its HTML string.\r\n *\r\n * @param {HTMLCanvasElement} canvasElm - The canvas element to convert.\r\n * @returns {HTMLImageElement | null} - HTML Element of the image.\r\n * @private\r\n */\r\n private canvasToImageHtml(canvasElm: HTMLCanvasElement): HTMLImageElement | null {\r\n try {\r\n const dataUrl = canvasElm.toDataURL(); // may throw if canvas is tainted\r\n const img = this.document.createElement('img');\r\n img.src = dataUrl;\r\n img.style.maxWidth = '100%';\r\n\r\n // Preserve displayed size (not just bitmap size)\r\n const rect = canvasElm.getBoundingClientRect();\r\n if (rect.width) img.style.width = `${rect.width}px`;\r\n if (rect.height) img.style.height = `${rect.height}px`;\r\n\r\n return img;\r\n } catch (err) {\r\n console.warn(`Canvas conversion failed for ${canvasElm}. Likely the canvas is tainted:`, err);\r\n // If toDataURL() fails (e.g., tainted canvas), keep canvas as-is in print output\r\n return null;\r\n }\r\n }\r\n\r\n /**\r\n * Includes canvas contents in the print section via img tags.\r\n *\r\n * @private\r\n * @param source\r\n * @param clone\r\n */\r\n private updateCanvasToImage(source: HTMLElement, clone: HTMLElement): void {\r\n const sourceCanvases = source.querySelectorAll('canvas');\r\n const cloneCanvases = clone.querySelectorAll('canvas');\r\n\r\n for (let i = 0; i < sourceCanvases.length; i++) {\r\n const srcCanvas = sourceCanvases[i];\r\n const cloneCanvas = cloneCanvases[i];\r\n const img = this.canvasToImageHtml(srcCanvas);\r\n if (img) {\r\n cloneCanvas.replaceWith(img);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Retrieves the HTML content of a specified printing section.\r\n *\r\n * @param {string} printSectionId - Id of the printing section.\r\n * @returns {string | null} - HTML content of the printing section, or null if not found.\r\n * @private\r\n */\r\n private getHtmlContents(printSectionId: string): string | null {\r\n const sourceElm = this.document.getElementById(printSectionId);\r\n if (!sourceElm) return null;\r\n\r\n const cloneElm = sourceElm.cloneNode(true) as HTMLElement; // cloneNode(true) deep clones subtree\r\n\r\n this.syncFormValues(sourceElm, cloneElm);\r\n this.updateCanvasToImage(sourceElm, cloneElm);\r\n\r\n return cloneElm.innerHTML;\r\n }\r\n\r\n /**\r\n * Retrieves the HTML content of elements with the specified tag.\r\n *\r\n * @param {keyof HTMLElementTagNameMap} tag - HTML tag name.\r\n * @returns {string} - Concatenated outerHTML of elements with the specified tag.\r\n * @private\r\n */\r\n private getElementTag(tag: keyof HTMLElementTagNameMap): string {\r\n const html: string[] = [];\r\n const elements = this.document.getElementsByTagName(tag);\r\n for (const el of Array.from(elements)) {\r\n html.push((el as Element).outerHTML);\r\n }\r\n return html.join('\\r\\n');\r\n }\r\n\r\n //#endregion\r\n\r\n protected notifyPrintComplete() {\r\n this.printComplete.next();\r\n }\r\n\r\n /**\r\n * Prints the specified content using the provided print options.\r\n *\r\n * @public\r\n * @param printOptionInput - Options for printing.\r\n */\r\n protected print(printOptionInput?: Partial<PrintOptions>): void {\r\n const printOptions = new PrintOptions(printOptionInput);\r\n if (printOptions.printMethod === 'iframe') {\r\n this.printWithIframe(printOptions);\r\n } else {\r\n this.printWithWindow(printOptions);\r\n }\r\n }\r\n\r\n protected printWithWindow(printOptions: PrintOptions) {\r\n // If the openNewTab option is set to true, then set the popOut option to an empty string\r\n // This will cause the print dialog to open in a new tab.\r\n const popOut = printOptions.printMethod === 'tab' ? '' : 'top=0,left=0,height=auto,width=auto';\r\n\r\n const popupWin = window.open('', '_blank', popOut);\r\n\r\n if (!popupWin) {\r\n // the popup window could not be opened.\r\n console.error('Could not open print window.');\r\n return;\r\n }\r\n\r\n popupWin.document.open();\r\n // Create the HTML structure\r\n this.buildPrintDocument(popupWin.document, printOptions);\r\n\r\n popupWin.document.close();\r\n\r\n // Listen for the window closing\r\n const checkClosedInterval = setInterval(() => {\r\n if (popupWin.closed) {\r\n clearInterval(checkClosedInterval);\r\n this.notifyPrintComplete();\r\n }\r\n }, 500);\r\n\r\n popupWin.addEventListener('load', () => {\r\n if (!printOptions.previewOnly) {\r\n setTimeout(() => {\r\n popupWin.print();\r\n if (printOptions.closeWindow) popupWin.close();\r\n }, printOptions.printDelay || 0);\r\n }\r\n });\r\n }\r\n\r\n private printWithIframe(printOptions: PrintOptions): void {\r\n if (this._iframeElement) {\r\n this._iframeElement.remove();\r\n }\r\n this._iframeElement = this.document.createElement('iframe');\r\n const iframe = this._iframeElement;\r\n iframe.id = 'print-iframe-' + new Date().getTime();\r\n iframe.style.position = 'absolute';\r\n iframe.style.left = '-9999px';\r\n iframe.style.top = '-9999px';\r\n iframe.style.width = '0px';\r\n iframe.style.height = '0px';\r\n iframe.ariaHidden = 'true';\r\n\r\n this.document.body.appendChild(iframe);\r\n\r\n const iframeDoc = iframe.contentDocument || iframe.contentWindow?.document;\r\n if (!iframeDoc) {\r\n console.error('Could not access iframe document.');\r\n this.document.body.removeChild(iframe);\r\n return;\r\n }\r\n\r\n iframeDoc.open();\r\n const success = this.buildPrintDocument(iframeDoc, printOptions);\r\n if (!success) {\r\n iframeDoc.close();\r\n this.document.body.removeChild(iframe);\r\n return;\r\n }\r\n iframeDoc.close();\r\n\r\n iframe.onload = () => {\r\n const printWindow = iframe.contentWindow;\r\n if (!printWindow) {\r\n console.error('Could not access iframe window.');\r\n this.document.body.removeChild(iframe);\r\n return;\r\n }\r\n\r\n setTimeout(() => {\r\n if (printOptions.previewOnly) {\r\n return;\r\n }\r\n printWindow.focus();\r\n printWindow.print();\r\n\r\n const mediaQueryList = printWindow.matchMedia('print');\r\n const listener = (mql: MediaQueryListEvent) => {\r\n if (!mql.matches) {\r\n this.notifyPrintComplete();\r\n mediaQueryList.removeEventListener('change', listener);\r\n }\r\n };\r\n\r\n mediaQueryList.addEventListener('change', listener);\r\n }, printOptions.printDelay || 0);\r\n };\r\n }\r\n\r\n private prepareDocumentComponents(printOptions: PrintOptions) {\r\n let styles = '';\r\n let links = '';\r\n const baseTag = this.getElementTag('base');\r\n\r\n if (printOptions.useExistingCss) {\r\n styles = this.getElementTag('style');\r\n links = this.getElementTag('link');\r\n }\r\n\r\n const printContents = this.getHtmlContents(printOptions.printSectionId);\r\n\r\n return { styles, links, baseTag, printContents };\r\n }\r\n\r\n private buildPrintDocument(doc: Document, printOptions: PrintOptions): boolean {\r\n const components = this.prepareDocumentComponents(printOptions);\r\n\r\n if (!components.printContents) {\r\n console.error(`Print section with id \"${printOptions.printSectionId}\" not found.`);\r\n return false;\r\n }\r\n\r\n const html = doc.createElement('html');\r\n const head = doc.createElement('head');\r\n const body = doc.createElement('body');\r\n\r\n // Set title\r\n const title = doc.createElement('title');\r\n title.textContent = printOptions.printTitle || '';\r\n head.appendChild(title);\r\n\r\n // Add all head content\r\n if (components.baseTag) {\r\n head.innerHTML += components.baseTag;\r\n }\r\n head.innerHTML += this.returnStyleValues();\r\n head.innerHTML += this.returnStyleSheetLinkTags();\r\n head.innerHTML += components.styles;\r\n head.innerHTML += components.links;\r\n\r\n // Set body class and content\r\n if (printOptions.bodyClass) body.className = printOptions.bodyClass;\r\n body.innerHTML += components.printContents;\r\n\r\n // Assemble document\r\n html.appendChild(head);\r\n html.appendChild(body);\r\n doc.appendChild(html);\r\n\r\n return true;\r\n }\r\n}\r\n","import { Directive, Input, output } from '@angular/core';\r\nimport { PrintBase, PrintStyle } from './ngx-print.base';\r\nimport { PrintOptions } from './print-options';\r\nimport { take } from 'rxjs';\r\n\r\n@Directive({\r\n selector: '[ngxPrint]',\r\n standalone: true,\r\n host: {\r\n '(click)': 'print()',\r\n },\r\n})\r\nexport class NgxPrintDirective extends PrintBase {\r\n private printOptions = new PrintOptions();\r\n\r\n /**\r\n * Prevents the print dialog from opening on the window\r\n *\r\n * @memberof NgxPrintDirective\r\n */\r\n @Input() set previewOnly(value: boolean) {\r\n this.printOptions = { ...this.printOptions, previewOnly: value };\r\n }\r\n\r\n /**\r\n *\r\n *\r\n * @memberof NgxPrintDirective\r\n */\r\n @Input() set printSectionId(value: string) {\r\n this.printOptions = { ...this.printOptions, printSectionId: value };\r\n }\r\n\r\n /**\r\n *\r\n *\r\n * @memberof NgxPrintDirective\r\n */\r\n @Input() set printTitle(value: string) {\r\n this.printOptions = { ...this.printOptions, printTitle: value };\r\n }\r\n\r\n /**\r\n *\r\n *\r\n * @memberof NgxPrintDirective\r\n */\r\n @Input() set useExistingCss(value: boolean) {\r\n this.printOptions = { ...this.printOptions, useExistingCss: value };\r\n }\r\n\r\n /**\r\n * A delay in milliseconds to force the print dialog to wait before opened. Default: 0\r\n *\r\n * @memberof NgxPrintDirective\r\n */\r\n @Input() set printDelay(value: number) {\r\n this.printOptions = { ...this.printOptions, printDelay: value };\r\n }\r\n\r\n /**\r\n * Whether to close the window after print() returns.\r\n *\r\n */\r\n @Input() set closeWindow(value: boolean) {\r\n this.printOptions = { ...this.printOptions, closeWindow: value };\r\n }\r\n\r\n /**\r\n * Class attribute to apply to the body element.\r\n *\r\n */\r\n @Input() set bodyClass(value: string) {\r\n this.printOptions = { ...this.printOptions, bodyClass: value };\r\n }\r\n\r\n /**\r\n * Which PrintMethod (iframe/window/tab) to use.\r\n *\r\n */\r\n @Input() set printMethod(value: typeof PrintOptions.prototype.printMethod) {\r\n this.printOptions = { ...this.printOptions, printMethod: value };\r\n }\r\n\r\n /**\r\n *\r\n *\r\n * @memberof NgxPrintDirective\r\n */\r\n @Input()\r\n set printStyle(values: PrintStyle) {\r\n super.setPrintStyle(values);\r\n }\r\n\r\n /**\r\n * @memberof NgxPrintDirective\r\n * @param cssList\r\n */\r\n @Input()\r\n set styleSheetFile(cssList: string) {\r\n super.setStyleSheetFile(cssList);\r\n }\r\n\r\n /**\r\n *\r\n *\r\n * @memberof NgxPrintDirective\r\n */\r\n public override print(): void {\r\n super.print(this.printOptions);\r\n this.printComplete.pipe(take(1)).subscribe(() => {\r\n this.printCompleted.emit();\r\n });\r\n }\r\n\r\n readonly printCompleted = output<void>();\r\n}\r\n","import { NgModule } from '@angular/core';\r\nimport { NgxPrintDirective } from './ngx-print.directive';\r\n\r\n@NgModule({\r\n imports: [NgxPrintDirective],\r\n exports: [NgxPrintDirective],\r\n})\r\nexport class NgxPrintModule {}\r\n","import { Injectable } from '@angular/core';\r\nimport { PrintBase, PrintStyle } from './ngx-print.base';\r\nimport { PrintOptions } from './print-options';\r\n\r\n/**\r\n * Service for handling printing functionality in Angular applications.\r\n * Extends the base printing class (PrintBase).\r\n *\r\n * @export\r\n * @class NgxPrintService\r\n * @extends {PrintBase}\r\n */\r\n@Injectable({\r\n providedIn: 'root',\r\n})\r\nexport class NgxPrintService extends PrintBase {\r\n printComplete$ = this.printComplete.asObservable();\r\n\r\n /**\r\n * Initiates the printing process using the provided print options.\r\n *\r\n * @param {PrintOptions} printOptions - Options for configuring the printing process.\r\n * @memberof NgxPrintService\r\n * @returns {void}\r\n */\r\n public override print(printOptions?: Partial<PrintOptions>): void {\r\n // Call the print method in the parent class\r\n super.print(printOptions);\r\n }\r\n\r\n /**\r\n * Sets the print style for the printing process.\r\n *\r\n * @param {{ [key: string]: { [key: string]: string } }} values - A dictionary representing the print styles.\r\n * @memberof NgxPrintService\r\n * @setter\r\n */\r\n set printStyle(values: PrintStyle) {\r\n super.setPrintStyle(values);\r\n }\r\n\r\n /**\r\n * Sets the stylesheet file for the printing process.\r\n *\r\n * @param {string} cssList - A string representing the path to the stylesheet file.\r\n * @memberof NgxPrintService\r\n * @setter\r\n */\r\n set styleSheetFile(cssList: string) {\r\n super.setStyleSheetFile(cssList);\r\n }\r\n}\r\n","/*\r\n * Public API Surface of ngx-print\r\n */\r\nexport { NgxPrintDirective } from './lib/ngx-print.directive';\r\nexport { NgxPrintModule } from './lib/ngx-print.module';\r\nexport { NgxPrintService } from './lib/ngx-print.service';\r\nexport { PrintOptions } from './lib/print-options';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;MAAa,YAAY,CAAA;IACvB,cAAc,GAAG,EAAE;IACnB,UAAU,GAAG,EAAE;IACf,cAAc,GAAG,KAAK;IACtB,SAAS,GAAG,EAAE;IACd,WAAW,GAAgC,QAAQ;IACnD,WAAW,GAAG,KAAK;IACnB,WAAW,GAAG,IAAI;IAClB,UAAU,GAAG,CAAC;AAEd,IAAA,WAAA,CAAY,OAA+B,EAAA;QACzC,IAAI,OAAO,EAAE;AACX,YAAA,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC;QAC9B;IACF;AACD;;MCDY,SAAS,CAAA;AACZ,IAAA,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IAC3B,KAAK,GAAG,MAAM,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAE7C,IAAA,cAAc;IACd,WAAW,GAAa,EAAE;IAC1B,eAAe,GAAG,EAAE;AAClB,IAAA,aAAa,GAAG,IAAI,OAAO,EAA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Ac,GAAG,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE;AAElD;;;;;;AAMG;AACa,IAAA,KAAK,CAAC,YAAoC,EAAA;;AAExD,QAAA,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC;IAC3B;AAEA;;;;;;AAMG;IACH,IAAI,UAAU,CAAC,MAAkB,EAAA;AAC/B,QAAA,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC;IAC7B;AAEA;;;;;;AAMG;IACH,IAAI,cAAc,CAAC,OAAe,EAAA;AAChC,QAAA,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC;IAClC;uGAnCW,eAAe,EAAA,IAAA,EAAA,IAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAf,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,eAAe,cAFd,MAAM,EAAA,CAAA;;2FAEP,eAAe,EAAA,UAAA,EAAA,CAAA;kBAH3B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;ACdD;;AAEG;;ACFH;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ngx-print",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Plug n' Play Angular
|
|
3
|
+
"version": "22.0.0",
|
|
4
|
+
"description": "Plug n' Play Angular directive to print your stuff",
|
|
5
5
|
"author": "https://github.com/ngx-print/ngx-print/graphs/contributors",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
"sideEffects": false,
|
|
40
|
+
"type": "module",
|
|
40
41
|
"dependencies": {
|
|
41
42
|
"tslib": "^2.3.0"
|
|
42
43
|
}
|
package/types/ngx-print.d.ts
CHANGED
|
@@ -14,7 +14,14 @@ declare class PrintOptions {
|
|
|
14
14
|
constructor(options?: Partial<PrintOptions>);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
/** For example:
|
|
18
|
+
* {
|
|
19
|
+
* 'h2': { 'border': 'solid 1px' },
|
|
20
|
+
* 'h1': { 'color': 'red', 'border': '1px solid' },
|
|
21
|
+
* */
|
|
22
|
+
type PrintStyle = Record<string, Record<string, string>>;
|
|
17
23
|
declare class PrintBase {
|
|
24
|
+
private document;
|
|
18
25
|
private nonce;
|
|
19
26
|
private _iframeElement;
|
|
20
27
|
private _printStyle;
|
|
@@ -26,11 +33,7 @@ declare class PrintBase {
|
|
|
26
33
|
* @param {Object} values - Key-value pairs representing print styles.
|
|
27
34
|
* @protected
|
|
28
35
|
*/
|
|
29
|
-
protected setPrintStyle(values:
|
|
30
|
-
[key: string]: {
|
|
31
|
-
[key: string]: string;
|
|
32
|
-
};
|
|
33
|
-
}): void;
|
|
36
|
+
protected setPrintStyle(values: PrintStyle): void;
|
|
34
37
|
/**
|
|
35
38
|
*
|
|
36
39
|
*
|
|
@@ -53,40 +56,21 @@ declare class PrintBase {
|
|
|
53
56
|
* @protected
|
|
54
57
|
*/
|
|
55
58
|
protected setStyleSheetFile(cssList: string): void;
|
|
56
|
-
|
|
57
|
-
* Updates the default values for input elements.
|
|
58
|
-
*
|
|
59
|
-
* @param {HTMLCollectionOf<HTMLInputElement>} elements - Collection of input elements.
|
|
60
|
-
* @private
|
|
61
|
-
*/
|
|
62
|
-
private updateInputDefaults;
|
|
63
|
-
/**
|
|
64
|
-
* Updates the default values for select elements.
|
|
65
|
-
*
|
|
66
|
-
* @param {HTMLCollectionOf<HTMLSelectElement>} elements - Collection of select elements.
|
|
67
|
-
* @private
|
|
68
|
-
*/
|
|
69
|
-
private updateSelectDefaults;
|
|
70
|
-
/**
|
|
71
|
-
* Updates the default values for textarea elements.
|
|
72
|
-
*
|
|
73
|
-
* @param {HTMLCollectionOf<HTMLTextAreaElement>} elements - Collection of textarea elements.
|
|
74
|
-
* @private
|
|
75
|
-
*/
|
|
76
|
-
private updateTextAreaDefaults;
|
|
59
|
+
private syncFormValues;
|
|
77
60
|
/**
|
|
78
61
|
* Converts a canvas element to an image and returns its HTML string.
|
|
79
62
|
*
|
|
80
|
-
* @param {HTMLCanvasElement}
|
|
81
|
-
* @returns {
|
|
63
|
+
* @param {HTMLCanvasElement} canvasElm - The canvas element to convert.
|
|
64
|
+
* @returns {HTMLImageElement | null} - HTML Element of the image.
|
|
82
65
|
* @private
|
|
83
66
|
*/
|
|
84
67
|
private canvasToImageHtml;
|
|
85
68
|
/**
|
|
86
69
|
* Includes canvas contents in the print section via img tags.
|
|
87
70
|
*
|
|
88
|
-
* @param {HTMLCollectionOf<HTMLCanvasElement>} elements - Collection of canvas elements.
|
|
89
71
|
* @private
|
|
72
|
+
* @param source
|
|
73
|
+
* @param clone
|
|
90
74
|
*/
|
|
91
75
|
private updateCanvasToImage;
|
|
92
76
|
/**
|
|
@@ -109,10 +93,10 @@ declare class PrintBase {
|
|
|
109
93
|
/**
|
|
110
94
|
* Prints the specified content using the provided print options.
|
|
111
95
|
*
|
|
112
|
-
* @param {PrintOptions} printOptions - Options for printing.
|
|
113
96
|
* @public
|
|
97
|
+
* @param printOptionInput - Options for printing.
|
|
114
98
|
*/
|
|
115
|
-
protected print(
|
|
99
|
+
protected print(printOptionInput?: Partial<PrintOptions>): void;
|
|
116
100
|
protected printWithWindow(printOptions: PrintOptions): void;
|
|
117
101
|
private printWithIframe;
|
|
118
102
|
private prepareDocumentComponents;
|
|
@@ -173,11 +157,7 @@ declare class NgxPrintDirective extends PrintBase {
|
|
|
173
157
|
*
|
|
174
158
|
* @memberof NgxPrintDirective
|
|
175
159
|
*/
|
|
176
|
-
set printStyle(values:
|
|
177
|
-
[key: string]: {
|
|
178
|
-
[key: string]: string;
|
|
179
|
-
};
|
|
180
|
-
});
|
|
160
|
+
set printStyle(values: PrintStyle);
|
|
181
161
|
/**
|
|
182
162
|
* @memberof NgxPrintDirective
|
|
183
163
|
* @param cssList
|
|
@@ -217,7 +197,7 @@ declare class NgxPrintService extends PrintBase {
|
|
|
217
197
|
* @memberof NgxPrintService
|
|
218
198
|
* @returns {void}
|
|
219
199
|
*/
|
|
220
|
-
print(printOptions
|
|
200
|
+
print(printOptions?: Partial<PrintOptions>): void;
|
|
221
201
|
/**
|
|
222
202
|
* Sets the print style for the printing process.
|
|
223
203
|
*
|
|
@@ -225,11 +205,7 @@ declare class NgxPrintService extends PrintBase {
|
|
|
225
205
|
* @memberof NgxPrintService
|
|
226
206
|
* @setter
|
|
227
207
|
*/
|
|
228
|
-
set printStyle(values:
|
|
229
|
-
[key: string]: {
|
|
230
|
-
[key: string]: string;
|
|
231
|
-
};
|
|
232
|
-
});
|
|
208
|
+
set printStyle(values: PrintStyle);
|
|
233
209
|
/**
|
|
234
210
|
* Sets the stylesheet file for the printing process.
|
|
235
211
|
*
|
package/types/ngx-print.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngx-print.d.ts","sources":["../../../src/lib/print-options.ts","../../../src/lib/ngx-print.base.ts","../../../src/lib/ngx-print.directive.ts","../../../src/lib/ngx-print.module.ts","../../../src/lib/ngx-print.service.ts"],"
|
|
1
|
+
{"version":3,"file":"ngx-print.d.ts","sources":["../../../src/lib/print-options.ts","../../../src/lib/ngx-print.base.ts","../../../src/lib/ngx-print.directive.ts","../../../src/lib/ngx-print.module.ts","../../../src/lib/ngx-print.service.ts"],"mappings":";;;;AAAA,cAAa,YAAY;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEY,0BAAU,OAAO,CAAC,YAAY;AAK3C;;ACXD;;;;AAIO;AACD,KAAM,UAAU,GAAG,MAAM,SAAS,MAAM;AAE9C,cAGa,SAAS;;;;;;6BAOG,OAAA;AAGvB;;;;;AAKG;AACH,oCAAg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