@solidexpert/ngx-print 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +301 -3
- package/fesm2022/solidexpert-ngx-print.mjs +541 -0
- package/fesm2022/solidexpert-ngx-print.mjs.map +1 -0
- package/package.json +46 -4
- package/types/solidexpert-ngx-print.d.ts +262 -0
- package/types/solidexpert-ngx-print.d.ts.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 salem mnassri
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,301 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# @solidexpert/ngx-print
|
|
2
|
+
|
|
3
|
+
Maintained by [solidexpert-ltd](https://github.com/solidexpert-ltd).
|
|
4
|
+
|
|
5
|
+
This is the solidexpert line of [ngx-print](https://github.com/ngx-print/ngx-print). License and copyright stay with the original authors (see [LICENSE](LICENSE)).
|
|
6
|
+
|
|
7
|
+
**[Upstream live demo](https://ngx-print.github.io/ngx-print/)**
|
|
8
|
+
|
|
9
|
+
# ngx-print : *plug n' play Angular directive to print your stuff*
|
|
10
|
+
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.
|
|
11
|
+
***Enjoy! Contributions are so welcomed :)***
|
|
12
|
+
|
|
13
|
+
## Dependencies
|
|
14
|
+
|
|
15
|
+
| ngx-print | Angular |
|
|
16
|
+
| --------- | -------------- |
|
|
17
|
+
| 1.2.1 | 7.0.0 - 14.1.0 |
|
|
18
|
+
| 1.3.x | 15.0.0 |
|
|
19
|
+
| 1.4.x | 16.0.0 |
|
|
20
|
+
| 1.5.x | 17.0.0 |
|
|
21
|
+
| 2.x.x | 18.0.0 |
|
|
22
|
+
| 3.x.x | 19.0.0 |
|
|
23
|
+
| 20.x.x | 20.0.0 |
|
|
24
|
+
| 21.x.x | 21.0.0 |
|
|
25
|
+
| 22.x.x | 22.0.0 |
|
|
26
|
+
|
|
27
|
+
## Version Alignment Notice
|
|
28
|
+
|
|
29
|
+
Starting with version 20.0.0, this package aligns its major version with the Angular framework version for better
|
|
30
|
+
clarity and compatibility tracking. Version 20 is intended for Angular 20 and so on.
|
|
31
|
+
|
|
32
|
+
## Setup
|
|
33
|
+
|
|
34
|
+
**1-** In your root application folder run:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
$ npm install @solidexpert/ngx-print
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**2-** Once `ngx-print` is installed, you need to import the directive `NgxPrintDirective`:
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { NgxPrintDirective } from '@solidexpert/ngx-print';
|
|
44
|
+
|
|
45
|
+
@Component({
|
|
46
|
+
...
|
|
47
|
+
imports: [NgxPrintDirective]
|
|
48
|
+
...
|
|
49
|
+
})
|
|
50
|
+
export class PrintExampleComponent {}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**3-** Then plug n' play with it:
|
|
54
|
+
|
|
55
|
+
- Assuming you want to print the following HTML section:
|
|
56
|
+
|
|
57
|
+
```html
|
|
58
|
+
<div>
|
|
59
|
+
<!--Your html stuff that you want to print-->
|
|
60
|
+
</div>
|
|
61
|
+
<button>print</button> <!--Your relevant print button-->
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
- 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:
|
|
65
|
+
|
|
66
|
+
```html
|
|
67
|
+
<!--
|
|
68
|
+
1)- Add an ID here
|
|
69
|
+
-->
|
|
70
|
+
<div id="print-section">
|
|
71
|
+
<!--Your html stuff that you want to print-->
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
<!--
|
|
75
|
+
2)- Add the directive name in your button (ngxPrint),
|
|
76
|
+
3)- Affect your ID to printSectionId
|
|
77
|
+
-->
|
|
78
|
+
<button printSectionId="print-section" ngxPrint>print</button>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Optional properties
|
|
82
|
+
|
|
83
|
+
- You want a customized title for your printing window? Add `printTitle`:
|
|
84
|
+
|
|
85
|
+
```html
|
|
86
|
+
<div id="print-section">
|
|
87
|
+
<!-- ... -->
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<button printTitle="MyTitle"
|
|
91
|
+
printSectionId="print-section"
|
|
92
|
+
ngxPrint>print</button>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
`printTitle` also drives the filename browsers suggest when the user chooses "Save as PDF" from
|
|
96
|
+
the print dialog. For `printMethod="window"`/`"tab"` this happens naturally since the popup/tab
|
|
97
|
+
is its own top-level document. For `printMethod="iframe"`, ngx-print briefly swaps the host
|
|
98
|
+
page's `document.title` to `printTitle` around the print call (restoring it once printing
|
|
99
|
+
finishes) since browsers base that suggested filename on the host page's title rather than the
|
|
100
|
+
hidden iframe's.
|
|
101
|
+
|
|
102
|
+
- Customize the printing stylesheet (CSS) by adding styles to `printStyle`:
|
|
103
|
+
|
|
104
|
+
```html
|
|
105
|
+
<div id="print-section">
|
|
106
|
+
<!-- ... -->
|
|
107
|
+
</div>
|
|
108
|
+
|
|
109
|
+
<button [printStyle]="{h1 : {'color': 'red'}, h2 : {'border': 'solid 1px'}}"
|
|
110
|
+
printSectionId="print-section"
|
|
111
|
+
ngxPrint>print</button>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Here some simple styles were added to every `h1` & `h2` tags within the `div` where `print-section` is tagged to its `id` attribute.
|
|
115
|
+
|
|
116
|
+
`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`:
|
|
117
|
+
|
|
118
|
+
```html
|
|
119
|
+
<button printStyle="h1, h2 { color: red; } @media print { .no-print { display: none; } }"
|
|
120
|
+
printSectionId="print-section"
|
|
121
|
+
ngxPrint>print</button>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
- If you would like to use your existing CSS with media print you can add the `useExistingCss` attribute:
|
|
125
|
+
|
|
126
|
+
```html
|
|
127
|
+
<div id="print-section">
|
|
128
|
+
<!-- ... -->
|
|
129
|
+
</div>
|
|
130
|
+
|
|
131
|
+
<button [useExistingCss]="true"
|
|
132
|
+
printSectionId="print-section"
|
|
133
|
+
ngxPrint>print</button>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
- Import external stylesheets with `styleSheetFile` (comma-separated list):
|
|
137
|
+
|
|
138
|
+
```html
|
|
139
|
+
<div id="print-section">
|
|
140
|
+
<!-- ... -->
|
|
141
|
+
</div>
|
|
142
|
+
|
|
143
|
+
<button styleSheetFile="assets/css/custom1.css,assets/css/custom2.css"
|
|
144
|
+
printSectionId="print-section"
|
|
145
|
+
ngxPrint>print</button>
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
- Show a preview without opening the print dialog using `previewOnly`:
|
|
149
|
+
|
|
150
|
+
```html
|
|
151
|
+
<div id="print-section">
|
|
152
|
+
<!-- ... -->
|
|
153
|
+
</div>
|
|
154
|
+
|
|
155
|
+
<button [previewOnly]="true"
|
|
156
|
+
printSectionId="print-section"
|
|
157
|
+
ngxPrint>print</button>
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
- 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...":
|
|
161
|
+
|
|
162
|
+
```html
|
|
163
|
+
<div id="print-section">
|
|
164
|
+
<!-- ... -->
|
|
165
|
+
</div>
|
|
166
|
+
|
|
167
|
+
<button [closeWindow]="false"
|
|
168
|
+
printSectionId="print-section"
|
|
169
|
+
ngxPrint>print</button>
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
- 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:
|
|
173
|
+
|
|
174
|
+
```html
|
|
175
|
+
<div id="print-section">
|
|
176
|
+
<!-- ... -->
|
|
177
|
+
</div>
|
|
178
|
+
|
|
179
|
+
<button bodyClass="theme-dark"
|
|
180
|
+
printSectionId="print-section"
|
|
181
|
+
ngxPrint>print</button>
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
- 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):
|
|
185
|
+
|
|
186
|
+
```html
|
|
187
|
+
<!-- Default: opens a new popup window -->
|
|
188
|
+
<button printMethod="window"
|
|
189
|
+
printSectionId="print-section"
|
|
190
|
+
ngxPrint>print</button>
|
|
191
|
+
|
|
192
|
+
<!-- Opens a new browser tab -->
|
|
193
|
+
<button printMethod="tab"
|
|
194
|
+
printSectionId="print-section"
|
|
195
|
+
ngxPrint>print</button>
|
|
196
|
+
|
|
197
|
+
<!-- Prints silently via a hidden iframe (no popup) -->
|
|
198
|
+
<button printMethod="iframe"
|
|
199
|
+
printSectionId="print-section"
|
|
200
|
+
ngxPrint>print</button>
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
- 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:
|
|
204
|
+
|
|
205
|
+
```html
|
|
206
|
+
<button (printCompleted)="onPrintComplete()"
|
|
207
|
+
printSectionId="print-section"
|
|
208
|
+
ngxPrint>print
|
|
209
|
+
</button>
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Using NgxPrint as a service (v1.5+)
|
|
213
|
+
|
|
214
|
+
Inject the `NgxPrintService` into your component or service:
|
|
215
|
+
|
|
216
|
+
```ts
|
|
217
|
+
import { inject } from '@angular/core';
|
|
218
|
+
import { NgxPrintService, PrintOptions } from '@solidexpert/ngx-print';
|
|
219
|
+
|
|
220
|
+
private readonly printService = inject(NgxPrintService);
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Printing a Section
|
|
224
|
+
|
|
225
|
+
```ts
|
|
226
|
+
import { PrintOptions } from '@solidexpert/ngx-print';
|
|
227
|
+
|
|
228
|
+
printMe(): void {
|
|
229
|
+
const customPrintOptions = new PrintOptions({
|
|
230
|
+
printSectionId: 'print-section',
|
|
231
|
+
// add any other print options as needed
|
|
232
|
+
});
|
|
233
|
+
this.printService.print(customPrintOptions);
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Print Options Object
|
|
238
|
+
|
|
239
|
+
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:
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
printSectionId: string = '';
|
|
243
|
+
printTitle: string = '';
|
|
244
|
+
useExistingCss: boolean = false;
|
|
245
|
+
bodyClass: string = '';
|
|
246
|
+
printMethod: 'window' | 'tab' | 'iframe' = 'window';
|
|
247
|
+
previewOnly: boolean = false;
|
|
248
|
+
closeWindow: boolean = true;
|
|
249
|
+
printDelay: number = 0;
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
| Property | Type | Default | Description |
|
|
253
|
+
| ---------------- | ------------------------------- | ---------- |------------------------------------------------------------------------------|
|
|
254
|
+
| `printSectionId` | `string` | `''` | **Required.** The `id` of the element to print. |
|
|
255
|
+
| `printTitle` | `string` | `''` | Title shown in the print document; also the suggested Save-as-PDF filename. |
|
|
256
|
+
| `useExistingCss` | `boolean` | `false` | Copies `<style>` and `<link>` tags from the host page. |
|
|
257
|
+
| `bodyClass` | `string` | `''` | CSS class(es) applied to the print `<body>`. |
|
|
258
|
+
| `printMethod` | `'window' \| 'tab' \| 'iframe'` | `'window'` | Controls how printing is triggered: popup window, new tab, or silent iframe. |
|
|
259
|
+
| `previewOnly` | `boolean` | `false` | Opens the print target without triggering the print dialog. |
|
|
260
|
+
| `closeWindow` | `boolean` | `true` | Closes the popup window after printing (ignored for `iframe`). |
|
|
261
|
+
| `printDelay` | `number` | `0` | Delay in milliseconds before the print dialog is opened. |
|
|
262
|
+
|
|
263
|
+
### Setting PrintStyles or StyleSheets
|
|
264
|
+
|
|
265
|
+
```ts
|
|
266
|
+
// Optional: CSS as a key-value pair
|
|
267
|
+
this.printService.printStyle = styleSheet;
|
|
268
|
+
|
|
269
|
+
// Optional: CSS as a raw string
|
|
270
|
+
this.printService.printStyle = 'h1, h2 { color: red; }';
|
|
271
|
+
|
|
272
|
+
// Optional: path to a CSS file
|
|
273
|
+
this.printService.styleSheetFile = fileLocation;
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Waiting for the print to complete
|
|
277
|
+
|
|
278
|
+
`print()` returns a Promise that resolves once that print job completes. As with the directive's `printCompleted` event, it is impossible to tell whether the user printed or cancelled.
|
|
279
|
+
|
|
280
|
+
```ts
|
|
281
|
+
async printMe(): Promise<void> {
|
|
282
|
+
await this.printService.print({ printSectionId: 'print-section' });
|
|
283
|
+
console.log('Print completed!');
|
|
284
|
+
}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
> **Deprecated:** `printComplete$` (RxJS Observable) still works but will be removed in the next major version. To migrate, await the Promise returned by `print()` instead (see above). If you still need an Observable, wrap it: `from(this.printService.print(options))`.
|
|
288
|
+
|
|
289
|
+
## Content-Security-Policy (CSP) Support
|
|
290
|
+
|
|
291
|
+
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.
|
|
292
|
+
|
|
293
|
+
## Contributors :1st_place_medal:
|
|
294
|
+
|
|
295
|
+
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
|
|
296
|
+
|
|
297
|
+
## Donation
|
|
298
|
+
|
|
299
|
+
Did this project help you reduce time? I won't say no to a cup of coffee 🍵 :)
|
|
300
|
+
|
|
301
|
+
[](https://www.paypal.me/selemxmn/2)
|
|
@@ -0,0 +1,541 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { CSP_NONCE, DOCUMENT, Directive, NgModule, Service, inject, input, output } from "@angular/core";
|
|
3
|
+
import { Subject } from "rxjs";
|
|
4
|
+
var PrintOptions = class {
|
|
5
|
+
printSectionId = "";
|
|
6
|
+
printTitle = "";
|
|
7
|
+
useExistingCss = false;
|
|
8
|
+
bodyClass = "";
|
|
9
|
+
printMethod = "window";
|
|
10
|
+
previewOnly = false;
|
|
11
|
+
closeWindow = true;
|
|
12
|
+
printDelay = 0;
|
|
13
|
+
constructor(options) {
|
|
14
|
+
if (options) Object.assign(this, options);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var PrintBase = class PrintBase {
|
|
18
|
+
document = inject(DOCUMENT);
|
|
19
|
+
nonce = inject(CSP_NONCE, { optional: true });
|
|
20
|
+
_iframeElement;
|
|
21
|
+
_printStyle = [];
|
|
22
|
+
_styleSheetFile = "";
|
|
23
|
+
printComplete = new Subject();
|
|
24
|
+
setPrintStyle(values) {
|
|
25
|
+
if (typeof values === "string") {
|
|
26
|
+
this._printStyle = values ? [values] : [];
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
this._printStyle = [];
|
|
30
|
+
for (const [selector, declarations] of Object.entries(values)) {
|
|
31
|
+
const body = Object.entries(declarations).map(([property, value]) => `${property}:${value}`).join(";");
|
|
32
|
+
this._printStyle.push(`${selector}{${body}}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
returnStyleValues() {
|
|
36
|
+
return `<style${this.nonce ? ` nonce="${this.nonce}"` : ""}> ${this._printStyle.join(" ")} </style>`;
|
|
37
|
+
}
|
|
38
|
+
returnStyleSheetLinkTags() {
|
|
39
|
+
return this._styleSheetFile;
|
|
40
|
+
}
|
|
41
|
+
setStyleSheetFile(cssList) {
|
|
42
|
+
if (!cssList) {
|
|
43
|
+
this._styleSheetFile = "";
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const files = cssList.split(",").map((f) => f.trim());
|
|
47
|
+
const nonceAttr = this.nonce ? ` nonce="${this.nonce}"` : "";
|
|
48
|
+
this._styleSheetFile = files.map((url) => `<link${nonceAttr} rel="stylesheet" type="text/css" href="${url}">`).join("");
|
|
49
|
+
}
|
|
50
|
+
syncFormValues(source, clone) {
|
|
51
|
+
const selector = "input, select, textarea";
|
|
52
|
+
const sourceEls = source.querySelectorAll(selector);
|
|
53
|
+
const cloneEls = clone.querySelectorAll(selector);
|
|
54
|
+
for (let i = 0; i < sourceEls.length; i++) {
|
|
55
|
+
const srcNode = sourceEls[i];
|
|
56
|
+
const cloneNode = cloneEls[i];
|
|
57
|
+
if (srcNode instanceof HTMLInputElement) {
|
|
58
|
+
if (srcNode.type === "checkbox" || srcNode.type === "radio") {
|
|
59
|
+
if (srcNode.checked) cloneNode.setAttribute("checked", "");
|
|
60
|
+
else cloneNode.removeAttribute("checked");
|
|
61
|
+
} else if (srcNode.type === "file") continue;
|
|
62
|
+
else cloneNode.setAttribute("value", srcNode.value);
|
|
63
|
+
} else if (srcNode instanceof HTMLTextAreaElement) cloneNode.textContent = srcNode.value;
|
|
64
|
+
else if (srcNode instanceof HTMLSelectElement) Array.from(cloneNode.options).forEach((opt, idx) => {
|
|
65
|
+
if (idx === srcNode.selectedIndex) opt.setAttribute("selected", "");
|
|
66
|
+
else opt.removeAttribute("selected");
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
canvasToImageHtml(canvasElm) {
|
|
71
|
+
try {
|
|
72
|
+
const dataUrl = canvasElm.toDataURL();
|
|
73
|
+
const img = this.document.createElement("img");
|
|
74
|
+
img.src = dataUrl;
|
|
75
|
+
img.style.maxWidth = "100%";
|
|
76
|
+
const rect = canvasElm.getBoundingClientRect();
|
|
77
|
+
if (rect.width) img.style.width = `${rect.width}px`;
|
|
78
|
+
if (rect.height) img.style.height = `${rect.height}px`;
|
|
79
|
+
return img;
|
|
80
|
+
} catch (err) {
|
|
81
|
+
console.warn(`Canvas conversion failed for ${canvasElm}. Likely the canvas is tainted:`, err);
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
updateCanvasToImage(source, clone) {
|
|
86
|
+
const sourceCanvases = source.querySelectorAll("canvas");
|
|
87
|
+
const cloneCanvases = clone.querySelectorAll("canvas");
|
|
88
|
+
for (let i = 0; i < sourceCanvases.length; i++) {
|
|
89
|
+
const srcCanvas = sourceCanvases[i];
|
|
90
|
+
const cloneCanvas = cloneCanvases[i];
|
|
91
|
+
const img = this.canvasToImageHtml(srcCanvas);
|
|
92
|
+
if (img) cloneCanvas.replaceWith(img);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
getHtmlContents(printSectionId) {
|
|
96
|
+
const sourceElm = this.document.getElementById(printSectionId);
|
|
97
|
+
if (!sourceElm) return null;
|
|
98
|
+
const cloneElm = sourceElm.cloneNode(true);
|
|
99
|
+
this.syncFormValues(sourceElm, cloneElm);
|
|
100
|
+
this.updateCanvasToImage(sourceElm, cloneElm);
|
|
101
|
+
return cloneElm.outerHTML;
|
|
102
|
+
}
|
|
103
|
+
getElementTag(tag) {
|
|
104
|
+
const html = [];
|
|
105
|
+
const elements = this.document.getElementsByTagName(tag);
|
|
106
|
+
for (const el of Array.from(elements)) html.push(el.outerHTML);
|
|
107
|
+
return html.join("\r\n");
|
|
108
|
+
}
|
|
109
|
+
print(printOptionInput) {
|
|
110
|
+
const printOptions = new PrintOptions(printOptionInput);
|
|
111
|
+
return new Promise((resolve) => {
|
|
112
|
+
const onComplete = () => {
|
|
113
|
+
this.printComplete.next();
|
|
114
|
+
resolve();
|
|
115
|
+
};
|
|
116
|
+
const components = this.prepareDocumentComponents(printOptions);
|
|
117
|
+
if (!components.printContents) {
|
|
118
|
+
console.error(`Print section with id "${printOptions.printSectionId}" not found.`);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const target = printOptions.printMethod === "iframe" ? this.createIframeTarget(printOptions, onComplete) : this.createWindowTarget(printOptions, onComplete);
|
|
122
|
+
if (target) this.runPrint(target, printOptions, components);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
runPrint(target, printOptions, components) {
|
|
126
|
+
target.doc.open();
|
|
127
|
+
this.buildPrintDocument(target.doc, printOptions, components);
|
|
128
|
+
target.doc.close();
|
|
129
|
+
target.onLoad(() => {
|
|
130
|
+
if (printOptions.previewOnly) return;
|
|
131
|
+
setTimeout(() => target.print(), printOptions.printDelay || 0);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
createWindowTarget(printOptions, onComplete) {
|
|
135
|
+
const popOut = printOptions.printMethod === "tab" ? "" : "top=0,left=0,height=auto,width=auto";
|
|
136
|
+
const popupWin = window.open("", "_blank", popOut);
|
|
137
|
+
if (!popupWin) {
|
|
138
|
+
console.error("Could not open print window.");
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
const checkClosedInterval = setInterval(() => {
|
|
142
|
+
if (popupWin.closed) {
|
|
143
|
+
clearInterval(checkClosedInterval);
|
|
144
|
+
onComplete();
|
|
145
|
+
}
|
|
146
|
+
}, 500);
|
|
147
|
+
return {
|
|
148
|
+
doc: popupWin.document,
|
|
149
|
+
onLoad: (callback) => popupWin.addEventListener("load", callback),
|
|
150
|
+
print: () => {
|
|
151
|
+
popupWin.print();
|
|
152
|
+
if (printOptions.closeWindow) popupWin.close();
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
createIframeTarget(printOptions, onComplete) {
|
|
157
|
+
this._iframeElement?.remove();
|
|
158
|
+
this._iframeElement = this.document.createElement("iframe");
|
|
159
|
+
const iframe = this._iframeElement;
|
|
160
|
+
iframe.id = "print-iframe-" + (/* @__PURE__ */ new Date()).getTime();
|
|
161
|
+
iframe.style.position = "absolute";
|
|
162
|
+
iframe.style.left = "-9999px";
|
|
163
|
+
iframe.style.top = "-9999px";
|
|
164
|
+
iframe.style.width = "0px";
|
|
165
|
+
iframe.style.height = "0px";
|
|
166
|
+
iframe.ariaHidden = "true";
|
|
167
|
+
this.document.body.appendChild(iframe);
|
|
168
|
+
const printWindow = iframe.contentWindow;
|
|
169
|
+
const iframeDoc = iframe.contentDocument || printWindow?.document;
|
|
170
|
+
if (!printWindow || !iframeDoc) {
|
|
171
|
+
console.error("Could not access iframe document.");
|
|
172
|
+
iframe.remove();
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
return {
|
|
176
|
+
doc: iframeDoc,
|
|
177
|
+
onLoad: (callback) => iframe.onload = callback,
|
|
178
|
+
print: () => {
|
|
179
|
+
const originalTitle = this.document.title;
|
|
180
|
+
if (printOptions.printTitle) this.document.title = printOptions.printTitle;
|
|
181
|
+
const mediaQueryList = printWindow.matchMedia("print");
|
|
182
|
+
const listener = (mql) => {
|
|
183
|
+
if (!mql.matches) {
|
|
184
|
+
this.document.title = originalTitle;
|
|
185
|
+
onComplete();
|
|
186
|
+
mediaQueryList.removeEventListener("change", listener);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
mediaQueryList.addEventListener("change", listener);
|
|
190
|
+
printWindow.focus();
|
|
191
|
+
printWindow.print();
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
prepareDocumentComponents(printOptions) {
|
|
196
|
+
let styles = "";
|
|
197
|
+
let links = "";
|
|
198
|
+
const baseTag = this.getElementTag("base");
|
|
199
|
+
if (printOptions.useExistingCss) {
|
|
200
|
+
styles = this.getElementTag("style");
|
|
201
|
+
links = this.getElementTag("link");
|
|
202
|
+
}
|
|
203
|
+
const printContents = this.getHtmlContents(printOptions.printSectionId);
|
|
204
|
+
return {
|
|
205
|
+
styles,
|
|
206
|
+
links,
|
|
207
|
+
baseTag,
|
|
208
|
+
printContents
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
buildPrintDocument(doc, printOptions, components) {
|
|
212
|
+
const html = doc.createElement("html");
|
|
213
|
+
const head = doc.createElement("head");
|
|
214
|
+
const body = doc.createElement("body");
|
|
215
|
+
const title = doc.createElement("title");
|
|
216
|
+
title.textContent = printOptions.printTitle || "";
|
|
217
|
+
head.appendChild(title);
|
|
218
|
+
if (components.baseTag) head.innerHTML += components.baseTag;
|
|
219
|
+
head.innerHTML += this.returnStyleValues();
|
|
220
|
+
head.innerHTML += this.returnStyleSheetLinkTags();
|
|
221
|
+
head.innerHTML += components.styles;
|
|
222
|
+
head.innerHTML += components.links;
|
|
223
|
+
if (printOptions.bodyClass) body.className = printOptions.bodyClass;
|
|
224
|
+
body.innerHTML += components.printContents;
|
|
225
|
+
html.appendChild(head);
|
|
226
|
+
html.appendChild(body);
|
|
227
|
+
doc.appendChild(html);
|
|
228
|
+
}
|
|
229
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
230
|
+
minVersion: "12.0.0",
|
|
231
|
+
version: "22.3.0",
|
|
232
|
+
ngImport: i0,
|
|
233
|
+
type: PrintBase,
|
|
234
|
+
deps: [],
|
|
235
|
+
target: i0.ɵɵFactoryTarget.Service
|
|
236
|
+
});
|
|
237
|
+
static ɵprov = i0.ɵɵngDeclareService({
|
|
238
|
+
minVersion: "22.0.0",
|
|
239
|
+
version: "22.3.0",
|
|
240
|
+
ngImport: i0,
|
|
241
|
+
type: PrintBase
|
|
242
|
+
});
|
|
243
|
+
};
|
|
244
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
245
|
+
minVersion: "12.0.0",
|
|
246
|
+
version: "22.3.0",
|
|
247
|
+
ngImport: i0,
|
|
248
|
+
type: PrintBase,
|
|
249
|
+
decorators: [{ type: Service }]
|
|
250
|
+
});
|
|
251
|
+
var NgxPrintDirective = class NgxPrintDirective extends PrintBase {
|
|
252
|
+
previewOnly = input(false, ...ngDevMode ? [{ debugName: "previewOnly" }] : /* istanbul ignore next */ []);
|
|
253
|
+
printSectionId = input("", ...ngDevMode ? [{ debugName: "printSectionId" }] : /* istanbul ignore next */ []);
|
|
254
|
+
printTitle = input("", ...ngDevMode ? [{ debugName: "printTitle" }] : /* istanbul ignore next */ []);
|
|
255
|
+
useExistingCss = input(false, ...ngDevMode ? [{ debugName: "useExistingCss" }] : /* istanbul ignore next */ []);
|
|
256
|
+
printDelay = input(0, ...ngDevMode ? [{ debugName: "printDelay" }] : /* istanbul ignore next */ []);
|
|
257
|
+
closeWindow = input(true, ...ngDevMode ? [{ debugName: "closeWindow" }] : /* istanbul ignore next */ []);
|
|
258
|
+
bodyClass = input("", ...ngDevMode ? [{ debugName: "bodyClass" }] : /* istanbul ignore next */ []);
|
|
259
|
+
printMethod = input("window", ...ngDevMode ? [{ debugName: "printMethod" }] : /* istanbul ignore next */ []);
|
|
260
|
+
printStyle = input({}, ...ngDevMode ? [{ debugName: "printStyle" }] : /* istanbul ignore next */ []);
|
|
261
|
+
styleSheetFile = input("", ...ngDevMode ? [{ debugName: "styleSheetFile" }] : /* istanbul ignore next */ []);
|
|
262
|
+
printCompleted = output();
|
|
263
|
+
print() {
|
|
264
|
+
super.setPrintStyle(this.printStyle());
|
|
265
|
+
super.setStyleSheetFile(this.styleSheetFile());
|
|
266
|
+
return super.print({
|
|
267
|
+
printSectionId: this.printSectionId(),
|
|
268
|
+
printTitle: this.printTitle(),
|
|
269
|
+
useExistingCss: this.useExistingCss(),
|
|
270
|
+
bodyClass: this.bodyClass(),
|
|
271
|
+
printMethod: this.printMethod(),
|
|
272
|
+
previewOnly: this.previewOnly(),
|
|
273
|
+
closeWindow: this.closeWindow(),
|
|
274
|
+
printDelay: this.printDelay()
|
|
275
|
+
}).then(() => this.printCompleted.emit());
|
|
276
|
+
}
|
|
277
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
278
|
+
minVersion: "12.0.0",
|
|
279
|
+
version: "22.3.0",
|
|
280
|
+
ngImport: i0,
|
|
281
|
+
type: NgxPrintDirective,
|
|
282
|
+
deps: null,
|
|
283
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
284
|
+
});
|
|
285
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
286
|
+
minVersion: "17.1.0",
|
|
287
|
+
version: "22.3.0",
|
|
288
|
+
type: NgxPrintDirective,
|
|
289
|
+
isStandalone: true,
|
|
290
|
+
selector: "[ngxPrint]",
|
|
291
|
+
inputs: {
|
|
292
|
+
previewOnly: {
|
|
293
|
+
classPropertyName: "previewOnly",
|
|
294
|
+
publicName: "previewOnly",
|
|
295
|
+
isSignal: true,
|
|
296
|
+
isRequired: false,
|
|
297
|
+
transformFunction: null
|
|
298
|
+
},
|
|
299
|
+
printSectionId: {
|
|
300
|
+
classPropertyName: "printSectionId",
|
|
301
|
+
publicName: "printSectionId",
|
|
302
|
+
isSignal: true,
|
|
303
|
+
isRequired: false,
|
|
304
|
+
transformFunction: null
|
|
305
|
+
},
|
|
306
|
+
printTitle: {
|
|
307
|
+
classPropertyName: "printTitle",
|
|
308
|
+
publicName: "printTitle",
|
|
309
|
+
isSignal: true,
|
|
310
|
+
isRequired: false,
|
|
311
|
+
transformFunction: null
|
|
312
|
+
},
|
|
313
|
+
useExistingCss: {
|
|
314
|
+
classPropertyName: "useExistingCss",
|
|
315
|
+
publicName: "useExistingCss",
|
|
316
|
+
isSignal: true,
|
|
317
|
+
isRequired: false,
|
|
318
|
+
transformFunction: null
|
|
319
|
+
},
|
|
320
|
+
printDelay: {
|
|
321
|
+
classPropertyName: "printDelay",
|
|
322
|
+
publicName: "printDelay",
|
|
323
|
+
isSignal: true,
|
|
324
|
+
isRequired: false,
|
|
325
|
+
transformFunction: null
|
|
326
|
+
},
|
|
327
|
+
closeWindow: {
|
|
328
|
+
classPropertyName: "closeWindow",
|
|
329
|
+
publicName: "closeWindow",
|
|
330
|
+
isSignal: true,
|
|
331
|
+
isRequired: false,
|
|
332
|
+
transformFunction: null
|
|
333
|
+
},
|
|
334
|
+
bodyClass: {
|
|
335
|
+
classPropertyName: "bodyClass",
|
|
336
|
+
publicName: "bodyClass",
|
|
337
|
+
isSignal: true,
|
|
338
|
+
isRequired: false,
|
|
339
|
+
transformFunction: null
|
|
340
|
+
},
|
|
341
|
+
printMethod: {
|
|
342
|
+
classPropertyName: "printMethod",
|
|
343
|
+
publicName: "printMethod",
|
|
344
|
+
isSignal: true,
|
|
345
|
+
isRequired: false,
|
|
346
|
+
transformFunction: null
|
|
347
|
+
},
|
|
348
|
+
printStyle: {
|
|
349
|
+
classPropertyName: "printStyle",
|
|
350
|
+
publicName: "printStyle",
|
|
351
|
+
isSignal: true,
|
|
352
|
+
isRequired: false,
|
|
353
|
+
transformFunction: null
|
|
354
|
+
},
|
|
355
|
+
styleSheetFile: {
|
|
356
|
+
classPropertyName: "styleSheetFile",
|
|
357
|
+
publicName: "styleSheetFile",
|
|
358
|
+
isSignal: true,
|
|
359
|
+
isRequired: false,
|
|
360
|
+
transformFunction: null
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
outputs: { printCompleted: "printCompleted" },
|
|
364
|
+
host: { listeners: { "click": "print()" } },
|
|
365
|
+
usesInheritance: true,
|
|
366
|
+
ngImport: i0
|
|
367
|
+
});
|
|
368
|
+
};
|
|
369
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
370
|
+
minVersion: "12.0.0",
|
|
371
|
+
version: "22.3.0",
|
|
372
|
+
ngImport: i0,
|
|
373
|
+
type: NgxPrintDirective,
|
|
374
|
+
decorators: [{
|
|
375
|
+
type: Directive,
|
|
376
|
+
args: [{
|
|
377
|
+
selector: "[ngxPrint]",
|
|
378
|
+
standalone: true,
|
|
379
|
+
host: { "(click)": "print()" }
|
|
380
|
+
}]
|
|
381
|
+
}],
|
|
382
|
+
propDecorators: {
|
|
383
|
+
previewOnly: [{
|
|
384
|
+
type: i0.Input,
|
|
385
|
+
args: [{
|
|
386
|
+
isSignal: true,
|
|
387
|
+
alias: "previewOnly",
|
|
388
|
+
required: false
|
|
389
|
+
}]
|
|
390
|
+
}],
|
|
391
|
+
printSectionId: [{
|
|
392
|
+
type: i0.Input,
|
|
393
|
+
args: [{
|
|
394
|
+
isSignal: true,
|
|
395
|
+
alias: "printSectionId",
|
|
396
|
+
required: false
|
|
397
|
+
}]
|
|
398
|
+
}],
|
|
399
|
+
printTitle: [{
|
|
400
|
+
type: i0.Input,
|
|
401
|
+
args: [{
|
|
402
|
+
isSignal: true,
|
|
403
|
+
alias: "printTitle",
|
|
404
|
+
required: false
|
|
405
|
+
}]
|
|
406
|
+
}],
|
|
407
|
+
useExistingCss: [{
|
|
408
|
+
type: i0.Input,
|
|
409
|
+
args: [{
|
|
410
|
+
isSignal: true,
|
|
411
|
+
alias: "useExistingCss",
|
|
412
|
+
required: false
|
|
413
|
+
}]
|
|
414
|
+
}],
|
|
415
|
+
printDelay: [{
|
|
416
|
+
type: i0.Input,
|
|
417
|
+
args: [{
|
|
418
|
+
isSignal: true,
|
|
419
|
+
alias: "printDelay",
|
|
420
|
+
required: false
|
|
421
|
+
}]
|
|
422
|
+
}],
|
|
423
|
+
closeWindow: [{
|
|
424
|
+
type: i0.Input,
|
|
425
|
+
args: [{
|
|
426
|
+
isSignal: true,
|
|
427
|
+
alias: "closeWindow",
|
|
428
|
+
required: false
|
|
429
|
+
}]
|
|
430
|
+
}],
|
|
431
|
+
bodyClass: [{
|
|
432
|
+
type: i0.Input,
|
|
433
|
+
args: [{
|
|
434
|
+
isSignal: true,
|
|
435
|
+
alias: "bodyClass",
|
|
436
|
+
required: false
|
|
437
|
+
}]
|
|
438
|
+
}],
|
|
439
|
+
printMethod: [{
|
|
440
|
+
type: i0.Input,
|
|
441
|
+
args: [{
|
|
442
|
+
isSignal: true,
|
|
443
|
+
alias: "printMethod",
|
|
444
|
+
required: false
|
|
445
|
+
}]
|
|
446
|
+
}],
|
|
447
|
+
printStyle: [{
|
|
448
|
+
type: i0.Input,
|
|
449
|
+
args: [{
|
|
450
|
+
isSignal: true,
|
|
451
|
+
alias: "printStyle",
|
|
452
|
+
required: false
|
|
453
|
+
}]
|
|
454
|
+
}],
|
|
455
|
+
styleSheetFile: [{
|
|
456
|
+
type: i0.Input,
|
|
457
|
+
args: [{
|
|
458
|
+
isSignal: true,
|
|
459
|
+
alias: "styleSheetFile",
|
|
460
|
+
required: false
|
|
461
|
+
}]
|
|
462
|
+
}],
|
|
463
|
+
printCompleted: [{
|
|
464
|
+
type: i0.Output,
|
|
465
|
+
args: ["printCompleted"]
|
|
466
|
+
}]
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
var NgxPrintModule = class NgxPrintModule {
|
|
470
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
471
|
+
minVersion: "12.0.0",
|
|
472
|
+
version: "22.3.0",
|
|
473
|
+
ngImport: i0,
|
|
474
|
+
type: NgxPrintModule,
|
|
475
|
+
deps: [],
|
|
476
|
+
target: i0.ɵɵFactoryTarget.NgModule
|
|
477
|
+
});
|
|
478
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({
|
|
479
|
+
minVersion: "14.0.0",
|
|
480
|
+
version: "22.3.0",
|
|
481
|
+
ngImport: i0,
|
|
482
|
+
type: NgxPrintModule,
|
|
483
|
+
imports: [NgxPrintDirective],
|
|
484
|
+
exports: [NgxPrintDirective]
|
|
485
|
+
});
|
|
486
|
+
static ɵinj = i0.ɵɵngDeclareInjector({
|
|
487
|
+
minVersion: "12.0.0",
|
|
488
|
+
version: "22.3.0",
|
|
489
|
+
ngImport: i0,
|
|
490
|
+
type: NgxPrintModule
|
|
491
|
+
});
|
|
492
|
+
};
|
|
493
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
494
|
+
minVersion: "12.0.0",
|
|
495
|
+
version: "22.3.0",
|
|
496
|
+
ngImport: i0,
|
|
497
|
+
type: NgxPrintModule,
|
|
498
|
+
decorators: [{
|
|
499
|
+
type: NgModule,
|
|
500
|
+
args: [{
|
|
501
|
+
imports: [NgxPrintDirective],
|
|
502
|
+
exports: [NgxPrintDirective]
|
|
503
|
+
}]
|
|
504
|
+
}]
|
|
505
|
+
});
|
|
506
|
+
var NgxPrintService = class NgxPrintService extends PrintBase {
|
|
507
|
+
printComplete$ = this.printComplete.asObservable();
|
|
508
|
+
print(printOptions) {
|
|
509
|
+
return super.print(printOptions);
|
|
510
|
+
}
|
|
511
|
+
set printStyle(values) {
|
|
512
|
+
super.setPrintStyle(values);
|
|
513
|
+
}
|
|
514
|
+
set styleSheetFile(cssList) {
|
|
515
|
+
super.setStyleSheetFile(cssList);
|
|
516
|
+
}
|
|
517
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
518
|
+
minVersion: "12.0.0",
|
|
519
|
+
version: "22.3.0",
|
|
520
|
+
ngImport: i0,
|
|
521
|
+
type: NgxPrintService,
|
|
522
|
+
deps: [],
|
|
523
|
+
target: i0.ɵɵFactoryTarget.Service
|
|
524
|
+
});
|
|
525
|
+
static ɵprov = i0.ɵɵngDeclareService({
|
|
526
|
+
minVersion: "22.0.0",
|
|
527
|
+
version: "22.3.0",
|
|
528
|
+
ngImport: i0,
|
|
529
|
+
type: NgxPrintService
|
|
530
|
+
});
|
|
531
|
+
};
|
|
532
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
533
|
+
minVersion: "12.0.0",
|
|
534
|
+
version: "22.3.0",
|
|
535
|
+
ngImport: i0,
|
|
536
|
+
type: NgxPrintService,
|
|
537
|
+
decorators: [{ type: Service }]
|
|
538
|
+
});
|
|
539
|
+
export { NgxPrintDirective, NgxPrintModule, NgxPrintService, PrintOptions };
|
|
540
|
+
|
|
541
|
+
//# sourceMappingURL=solidexpert-ngx-print.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solidexpert-ngx-print.mjs","names":[],"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"],"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, Service } 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/**\r\n * Either a {@link PrintStyle} object, or a raw CSS string (e.g. `'h1 { color: red; }'`)\r\n * to be injected into the print document's <style> tag as-is.\r\n */\r\nexport type PrintStyleInput = PrintStyle | string;\r\n\r\n/** Everything copied from the host document into the print document. */\r\ninterface DocumentComponents {\r\n styles: string;\r\n links: string;\r\n baseTag: string;\r\n printContents: string | null;\r\n}\r\n\r\n/**\r\n * A document to print into, plus the parts of printing that differ per print method.\r\n * Completion detection is wired up by the factory that creates the target.\r\n */\r\ninterface PrintTarget {\r\n doc: Document;\r\n /** Runs `callback` once the written document has loaded. */\r\n onLoad(callback: () => void): void;\r\n /** Opens the print dialog. */\r\n print(): void;\r\n}\r\n\r\n@Service()\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 values - Either a key-value pairs object representing print styles, or a raw CSS string.\r\n * @protected\r\n */\r\n protected setPrintStyle(values: PrintStyleInput) {\r\n if (typeof values === 'string') {\r\n this._printStyle = values ? [values] : [];\r\n return;\r\n }\r\n\r\n this._printStyle = [];\r\n for (const [selector, declarations] of Object.entries(values)) {\r\n // Built declaration-by-declaration (rather than via JSON.stringify + a quote-stripping\r\n // regex) so that quotes and commas that are part of a CSS value (e.g. quoted font names,\r\n // comma-separated font-family fallback lists) survive instead of being stripped/mangled.\r\n const body = Object.entries(declarations)\r\n .map(([property, value]) => `${property}:${value}`)\r\n .join(';');\r\n this._printStyle.push(`${selector}{${body}}`);\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 public returnStyleValues(): string {\r\n const styleNonce = this.nonce ? ` nonce=\"${this.nonce}\"` : '';\r\n return `<style${styleNonce}> ${this._printStyle.join(' ')} </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 if (!cssList) {\r\n this._styleSheetFile = '';\r\n return;\r\n }\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.outerHTML;\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 /**\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 * @returns a Promise that resolves once this print job completes (the print dialog / window was closed).\r\n * It never settles if printing could not be started, or with `previewOnly` in iframe mode.\r\n */\r\n protected print(printOptionInput?: Partial<PrintOptions>): Promise<void> {\r\n const printOptions = new PrintOptions(printOptionInput);\r\n return new Promise<void>(resolve => {\r\n const onComplete = () => {\r\n this.printComplete.next(); // legacy\r\n resolve();\r\n };\r\n\r\n // Collected before any window/iframe is created, so a missing section never leaves an empty popup behind.\r\n const components = this.prepareDocumentComponents(printOptions);\r\n if (!components.printContents) {\r\n console.error(`Print section with id \"${printOptions.printSectionId}\" not found.`);\r\n return;\r\n }\r\n\r\n const target = printOptions.printMethod === 'iframe' ? this.createIframeTarget(printOptions, onComplete) : this.createWindowTarget(printOptions, onComplete);\r\n if (target) {\r\n this.runPrint(target, printOptions, components);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * The steps shared by every print method: write the document, wait for it to load,\r\n * then open the print dialog after `printDelay` (unless `previewOnly`).\r\n */\r\n private runPrint(target: PrintTarget, printOptions: PrintOptions, components: DocumentComponents): void {\r\n target.doc.open();\r\n this.buildPrintDocument(target.doc, printOptions, components);\r\n target.doc.close();\r\n\r\n target.onLoad(() => {\r\n if (printOptions.previewOnly) return;\r\n setTimeout(() => target.print(), printOptions.printDelay || 0);\r\n });\r\n }\r\n\r\n private createWindowTarget(printOptions: PrintOptions, onComplete: () => void): PrintTarget | null {\r\n // An empty features string makes the browser open a new tab instead of a popup window.\r\n const popOut = printOptions.printMethod === 'tab' ? '' : 'top=0,left=0,height=auto,width=auto';\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 null;\r\n }\r\n\r\n // Started right away (not when printing) so that closing a previewOnly window also completes.\r\n const checkClosedInterval = setInterval(() => {\r\n if (popupWin.closed) {\r\n clearInterval(checkClosedInterval);\r\n onComplete();\r\n }\r\n }, 500);\r\n\r\n return {\r\n doc: popupWin.document,\r\n onLoad: callback => popupWin.addEventListener('load', callback),\r\n print: () => {\r\n popupWin.print();\r\n if (printOptions.closeWindow) popupWin.close();\r\n },\r\n };\r\n }\r\n\r\n private createIframeTarget(printOptions: PrintOptions, onComplete: () => void): PrintTarget | null {\r\n this._iframeElement?.remove();\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 printWindow = iframe.contentWindow;\r\n const iframeDoc = iframe.contentDocument || printWindow?.document;\r\n if (!printWindow || !iframeDoc) {\r\n console.error('Could not access iframe document.');\r\n iframe.remove();\r\n return null;\r\n }\r\n\r\n return {\r\n doc: iframeDoc,\r\n onLoad: callback => (iframe.onload = callback),\r\n print: () => {\r\n // Browsers derive the suggested \"Save as PDF\" filename from the host page's\r\n // document.title, not the iframe's own <title> (unlike window/tab printing, where the popup/tab is itself the top-level context).\r\n // Swap it temporarily so printTitle is used as the suggested filename here too, restoring it once printing is done.\r\n const originalTitle = this.document.title;\r\n if (printOptions.printTitle) {\r\n this.document.title = printOptions.printTitle;\r\n }\r\n\r\n // Registered BEFORE print() is called: window.print() blocks script execution.\r\n // Registered only now (not at creation) so that printing the host page while a previewOnly iframe exists doesn't count as completion.\r\n const mediaQueryList = printWindow.matchMedia('print');\r\n const listener = (mql: MediaQueryListEvent) => {\r\n if (!mql.matches) {\r\n this.document.title = originalTitle;\r\n onComplete();\r\n mediaQueryList.removeEventListener('change', listener);\r\n }\r\n };\r\n mediaQueryList.addEventListener('change', listener);\r\n\r\n printWindow.focus();\r\n printWindow.print();\r\n },\r\n };\r\n }\r\n\r\n private prepareDocumentComponents(printOptions: PrintOptions): DocumentComponents {\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, components: DocumentComponents): void {\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}\r\n","import { Directive, input, output } from '@angular/core';\r\nimport { PrintBase, PrintStyleInput } from './ngx-print.base';\r\nimport { PrintOptions } from './print-options';\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 /**\r\n * Prevents the print dialog from opening on the window\r\n */\r\n readonly previewOnly = input(false);\r\n\r\n readonly printSectionId = input('');\r\n\r\n readonly printTitle = input('');\r\n\r\n readonly useExistingCss = input(false);\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 readonly printDelay = input(0);\r\n\r\n /**\r\n * Whether to close the window after print() returns.\r\n */\r\n readonly closeWindow = input(true);\r\n\r\n /**\r\n * Class attribute to apply to the body element.\r\n */\r\n readonly bodyClass = input('');\r\n\r\n /**\r\n * Which PrintMethod (iframe/window/tab) to use.\r\n */\r\n readonly printMethod = input<PrintOptions['printMethod']>('window');\r\n\r\n readonly printStyle = input<PrintStyleInput>({});\r\n\r\n readonly styleSheetFile = input('');\r\n\r\n readonly printCompleted = output<void>();\r\n\r\n public override print(): Promise<void> {\r\n // Inputs carry side effects on PrintBase's internal style state, so they're applied\r\n // synchronously here rather than via effect() (effects shouldn't propagate state).\r\n super.setPrintStyle(this.printStyle());\r\n super.setStyleSheetFile(this.styleSheetFile());\r\n\r\n const printed = super.print({\r\n printSectionId: this.printSectionId(),\r\n printTitle: this.printTitle(),\r\n useExistingCss: this.useExistingCss(),\r\n bodyClass: this.bodyClass(),\r\n printMethod: this.printMethod(),\r\n previewOnly: this.previewOnly(),\r\n closeWindow: this.closeWindow(),\r\n printDelay: this.printDelay(),\r\n });\r\n\r\n return printed.then(() => this.printCompleted.emit());\r\n }\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 { Service } from '@angular/core';\r\nimport { PrintBase, PrintStyleInput } 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@Service()\r\nexport class NgxPrintService extends PrintBase {\r\n /**\r\n * Emits every time a print job completes.\r\n *\r\n * @deprecated The RxJS-based API will be removed in the next major version.\r\n * Use the Promise returned by {@link NgxPrintService.print} instead, which resolves when that print job completes:\r\n *\r\n * ```ts\r\n * // Before\r\n * this.printService.printComplete$.pipe(take(1)).subscribe(() => onDone());\r\n * this.printService.print(options);\r\n *\r\n * // After\r\n * await this.printService.print(options);\r\n * onDone();\r\n * // or: this.printService.print(options).then(() => onDone());\r\n * ```\r\n *\r\n * If you still need an Observable, wrap the Promise yourself: `from(this.printService.print(options))`.\r\n */\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 {Promise<void>} Resolves once this print job completes (the print dialog / window was closed).\r\n * It cannot tell whether the user printed or cancelled, and it never settles if printing\r\n * could not be started (e.g. blocked popup, missing print section).\r\n */\r\n public override print(printOptions?: Partial<PrintOptions>): Promise<void> {\r\n // Call the print method in the parent class\r\n return super.print(printOptions);\r\n }\r\n\r\n /**\r\n * Sets the print style for the printing process.\r\n *\r\n * @param values - Either a dictionary representing the print styles, or a raw CSS string.\r\n * @memberof NgxPrintService\r\n * @setter\r\n */\r\n set printStyle(values: PrintStyleInput) {\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"],"mappings":";;;AAAA,IAAa,eAAb,MAAyB;CACvB,iBAAiB;CACjB,aAAa;CACb,iBAAiB;CACjB,YAAY;CACZ,cAA2C;CAC3C,cAAc;CACd,cAAc;CACd,aAAa;CAEb,YAAY,SAA+B;EACzC,IAAI,SACF,OAAO,OAAO,MAAM,OAAO;CAE/B;AACD;ACuBD,IAAa,YAAb,MAAa,UAAS;CACZ,WAAW,OAAO,QAAQ;CAC1B,QAAQ,OAAO,WAAW,EAAE,UAAU,KAAI,CAAE;CAE5C;CACA,cAAwB,CAAA;CACxB,kBAAkB;CAChB,gBAAgB,IAAI,QAAO;CAS3B,cAAc,QAAuB;EAC7C,IAAI,OAAO,WAAW,UAAU;GAC9B,KAAK,cAAc,SAAS,CAAC,MAAM,IAAI,CAAA;GACvC;EACF;EAEA,KAAK,cAAc,CAAA;EACnB,KAAK,MAAM,CAAC,UAAU,iBAAiB,OAAO,QAAQ,MAAM,GAAG;GAI7D,MAAM,OAAO,OAAO,QAAQ,YAAY,CAAC,CACtC,KAAK,CAAC,UAAU,WAAW,GAAG,SAAQ,GAAI,OAAO,CAAC,CAClD,KAAK,GAAG;GACX,KAAK,YAAY,KAAK,GAAG,SAAQ,GAAI,KAAI,EAAG;EAC9C;CACF;CAMO,oBAAiB;EAEtB,OAAO,SADY,KAAK,QAAQ,WAAW,KAAK,MAAK,KAAM,GACjC,IAAK,KAAK,YAAY,KAAK,GAAG,EAAC;CAC3D;CAOQ,2BAAwB;EAC9B,OAAO,KAAK;CACd;CASU,kBAAkB,SAAe;EACzC,IAAI,CAAC,SAAS;GACZ,KAAK,kBAAkB;GACvB;EACF;EACA,MAAM,QAAQ,QAAQ,MAAM,GAAG,CAAC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AiB;GAC3B,SAAS,CAAC,iBAAiB;EAC5B,CAAA;;;ACOD,IAAa,kBAAb,MAAa,wBAAwB,UAAS;CAoB5C,iBAAiB,KAAK,cAAc,aAAY;CAWhC,MAAM,cAAoC;EAExD,OAAO,MAAM,MAAM,YAAY;CACjC;CASA,IAAI,WAAW,QAAuB;EACpC,MAAM,cAAc,MAAM;CAC5B;CASA,IAAI,eAAe,SAAe;EAChC,MAAM,kBAAkB,OAAO;CACjC;CAxDW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAe,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAf,OAAA,QAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;CAAe,CAAA;;AAAf,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAe,YAAA,CAAA,EAD3B,MAAA,Q"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidexpert/ngx-print",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "22.0.0",
|
|
4
|
+
"description": "Plug n' Play Angular directive to print your stuff. Maintained by solidexpert-ltd. Upstream: https://github.com/ngx-print/ngx-print",
|
|
5
|
+
"author": "https://github.com/ngx-print/ngx-print/graphs/contributors",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/solidexpert-ltd/ngx-print.git"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/solidexpert-ltd/ngx-print/issues"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/solidexpert-ltd/ngx-print#readme",
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": "^22.22.3 || ^24.15.0 || >=26"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"print",
|
|
20
|
+
"angular",
|
|
21
|
+
"library",
|
|
22
|
+
"ng-print",
|
|
23
|
+
"ngx-print",
|
|
24
|
+
"directive",
|
|
25
|
+
"dependency",
|
|
26
|
+
"angular-print"
|
|
27
|
+
],
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"@angular/core": "^22.0.0",
|
|
30
|
+
"rxjs": "^7.8.2"
|
|
31
|
+
},
|
|
32
|
+
"module": "fesm2022/solidexpert-ngx-print.mjs",
|
|
33
|
+
"typings": "types/solidexpert-ngx-print.d.ts",
|
|
34
|
+
"exports": {
|
|
35
|
+
"./package.json": {
|
|
36
|
+
"default": "./package.json"
|
|
37
|
+
},
|
|
38
|
+
".": {
|
|
39
|
+
"types": "./types/solidexpert-ngx-print.d.ts",
|
|
40
|
+
"default": "./fesm2022/solidexpert-ngx-print.mjs"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"sideEffects": false,
|
|
44
|
+
"type": "module",
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"tslib": "^2.3.0"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated bundle index. Do not edit.
|
|
3
|
+
*/
|
|
4
|
+
import { Subject } from "rxjs";
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
export declare class PrintOptions {
|
|
7
|
+
printSectionId: string;
|
|
8
|
+
printTitle: string;
|
|
9
|
+
useExistingCss: boolean;
|
|
10
|
+
bodyClass: string;
|
|
11
|
+
printMethod: 'window' | 'tab' | 'iframe';
|
|
12
|
+
previewOnly: boolean;
|
|
13
|
+
closeWindow: boolean;
|
|
14
|
+
printDelay: number;
|
|
15
|
+
constructor(options?: Partial<PrintOptions>);
|
|
16
|
+
}
|
|
17
|
+
/** For example:
|
|
18
|
+
* {
|
|
19
|
+
* 'h2': { 'border': 'solid 1px' },
|
|
20
|
+
* 'h1': { 'color': 'red', 'border': '1px solid' },
|
|
21
|
+
* */
|
|
22
|
+
export type PrintStyle = Record<string, Record<string, string>>;
|
|
23
|
+
/**
|
|
24
|
+
* Either a {@link PrintStyle} object, or a raw CSS string (e.g. `'h1 { color: red; }'`)
|
|
25
|
+
* to be injected into the print document's <style> tag as-is.
|
|
26
|
+
*/
|
|
27
|
+
export type PrintStyleInput = PrintStyle | string;
|
|
28
|
+
declare class PrintBase {
|
|
29
|
+
private document;
|
|
30
|
+
private nonce;
|
|
31
|
+
private _iframeElement;
|
|
32
|
+
private _printStyle;
|
|
33
|
+
private _styleSheetFile;
|
|
34
|
+
protected printComplete: Subject<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Sets the print styles based on the provided values.
|
|
37
|
+
*
|
|
38
|
+
* @param values - Either a key-value pairs object representing print styles, or a raw CSS string.
|
|
39
|
+
* @protected
|
|
40
|
+
*/
|
|
41
|
+
protected setPrintStyle(values: PrintStyleInput): void;
|
|
42
|
+
/**
|
|
43
|
+
* @returns the string that create the stylesheet which will be injected
|
|
44
|
+
* later within <style></style> tag.
|
|
45
|
+
*/
|
|
46
|
+
returnStyleValues(): string;
|
|
47
|
+
/**
|
|
48
|
+
* @returns string which contains the link tags containing the css which will
|
|
49
|
+
* be injected later within <head></head> tag.
|
|
50
|
+
*
|
|
51
|
+
*/
|
|
52
|
+
private returnStyleSheetLinkTags;
|
|
53
|
+
/**
|
|
54
|
+
* Sets the style sheet file based on the provided CSS list.
|
|
55
|
+
*
|
|
56
|
+
* @param {string} cssList - CSS file or list of CSS files.
|
|
57
|
+
* @protected
|
|
58
|
+
*/
|
|
59
|
+
protected setStyleSheetFile(cssList: string): void;
|
|
60
|
+
private syncFormValues;
|
|
61
|
+
/**
|
|
62
|
+
* Converts a canvas element to an image and returns its HTML string.
|
|
63
|
+
*
|
|
64
|
+
* @param {HTMLCanvasElement} canvasElm - The canvas element to convert.
|
|
65
|
+
* @returns {HTMLImageElement | null} - HTML Element of the image.
|
|
66
|
+
* @private
|
|
67
|
+
*/
|
|
68
|
+
private canvasToImageHtml;
|
|
69
|
+
/**
|
|
70
|
+
* Includes canvas contents in the print section via img tags.
|
|
71
|
+
*
|
|
72
|
+
* @private
|
|
73
|
+
* @param source
|
|
74
|
+
* @param clone
|
|
75
|
+
*/
|
|
76
|
+
private updateCanvasToImage;
|
|
77
|
+
/**
|
|
78
|
+
* Retrieves the HTML content of a specified printing section.
|
|
79
|
+
*
|
|
80
|
+
* @param {string} printSectionId - Id of the printing section.
|
|
81
|
+
* @returns {string | null} - HTML content of the printing section, or null if not found.
|
|
82
|
+
* @private
|
|
83
|
+
*/
|
|
84
|
+
private getHtmlContents;
|
|
85
|
+
/**
|
|
86
|
+
* Retrieves the HTML content of elements with the specified tag.
|
|
87
|
+
*
|
|
88
|
+
* @param {keyof HTMLElementTagNameMap} tag - HTML tag name.
|
|
89
|
+
* @returns {string} - Concatenated outerHTML of elements with the specified tag.
|
|
90
|
+
* @private
|
|
91
|
+
*/
|
|
92
|
+
private getElementTag;
|
|
93
|
+
/**
|
|
94
|
+
* Prints the specified content using the provided print options.
|
|
95
|
+
*
|
|
96
|
+
* @public
|
|
97
|
+
* @param printOptionInput - Options for printing.
|
|
98
|
+
* @returns a Promise that resolves once this print job completes (the print dialog / window was closed).
|
|
99
|
+
* It never settles if printing could not be started, or with `previewOnly` in iframe mode.
|
|
100
|
+
*/
|
|
101
|
+
protected print(printOptionInput?: Partial<PrintOptions>): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* The steps shared by every print method: write the document, wait for it to load,
|
|
104
|
+
* then open the print dialog after `printDelay` (unless `previewOnly`).
|
|
105
|
+
*/
|
|
106
|
+
private runPrint;
|
|
107
|
+
private createWindowTarget;
|
|
108
|
+
private createIframeTarget;
|
|
109
|
+
private prepareDocumentComponents;
|
|
110
|
+
private buildPrintDocument;
|
|
111
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<PrintBase, never>;
|
|
112
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
113
|
+
}
|
|
114
|
+
export declare class NgxPrintDirective extends PrintBase {
|
|
115
|
+
/**
|
|
116
|
+
* Prevents the print dialog from opening on the window
|
|
117
|
+
*/
|
|
118
|
+
readonly previewOnly: import("@angular/core").InputSignal<boolean>;
|
|
119
|
+
readonly printSectionId: import("@angular/core").InputSignal<string>;
|
|
120
|
+
readonly printTitle: import("@angular/core").InputSignal<string>;
|
|
121
|
+
readonly useExistingCss: import("@angular/core").InputSignal<boolean>;
|
|
122
|
+
/**
|
|
123
|
+
* A delay in milliseconds to force the print dialog to wait before opened. Default: 0
|
|
124
|
+
*/
|
|
125
|
+
readonly printDelay: import("@angular/core").InputSignal<number>;
|
|
126
|
+
/**
|
|
127
|
+
* Whether to close the window after print() returns.
|
|
128
|
+
*/
|
|
129
|
+
readonly closeWindow: import("@angular/core").InputSignal<boolean>;
|
|
130
|
+
/**
|
|
131
|
+
* Class attribute to apply to the body element.
|
|
132
|
+
*/
|
|
133
|
+
readonly bodyClass: import("@angular/core").InputSignal<string>;
|
|
134
|
+
/**
|
|
135
|
+
* Which PrintMethod (iframe/window/tab) to use.
|
|
136
|
+
*/
|
|
137
|
+
readonly printMethod: import("@angular/core").InputSignal<"window" | "tab" | "iframe">;
|
|
138
|
+
readonly printStyle: import("@angular/core").InputSignal<PrintStyleInput>;
|
|
139
|
+
readonly styleSheetFile: import("@angular/core").InputSignal<string>;
|
|
140
|
+
readonly printCompleted: import("@angular/core").OutputEmitterRef<void>;
|
|
141
|
+
print(): Promise<void>;
|
|
142
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NgxPrintDirective, never>;
|
|
143
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<NgxPrintDirective, "[ngxPrint]", never, {
|
|
144
|
+
"previewOnly": {
|
|
145
|
+
"alias": "previewOnly";
|
|
146
|
+
"required": false;
|
|
147
|
+
"isSignal": true;
|
|
148
|
+
};
|
|
149
|
+
"printSectionId": {
|
|
150
|
+
"alias": "printSectionId";
|
|
151
|
+
"required": false;
|
|
152
|
+
"isSignal": true;
|
|
153
|
+
};
|
|
154
|
+
"printTitle": {
|
|
155
|
+
"alias": "printTitle";
|
|
156
|
+
"required": false;
|
|
157
|
+
"isSignal": true;
|
|
158
|
+
};
|
|
159
|
+
"useExistingCss": {
|
|
160
|
+
"alias": "useExistingCss";
|
|
161
|
+
"required": false;
|
|
162
|
+
"isSignal": true;
|
|
163
|
+
};
|
|
164
|
+
"printDelay": {
|
|
165
|
+
"alias": "printDelay";
|
|
166
|
+
"required": false;
|
|
167
|
+
"isSignal": true;
|
|
168
|
+
};
|
|
169
|
+
"closeWindow": {
|
|
170
|
+
"alias": "closeWindow";
|
|
171
|
+
"required": false;
|
|
172
|
+
"isSignal": true;
|
|
173
|
+
};
|
|
174
|
+
"bodyClass": {
|
|
175
|
+
"alias": "bodyClass";
|
|
176
|
+
"required": false;
|
|
177
|
+
"isSignal": true;
|
|
178
|
+
};
|
|
179
|
+
"printMethod": {
|
|
180
|
+
"alias": "printMethod";
|
|
181
|
+
"required": false;
|
|
182
|
+
"isSignal": true;
|
|
183
|
+
};
|
|
184
|
+
"printStyle": {
|
|
185
|
+
"alias": "printStyle";
|
|
186
|
+
"required": false;
|
|
187
|
+
"isSignal": true;
|
|
188
|
+
};
|
|
189
|
+
"styleSheetFile": {
|
|
190
|
+
"alias": "styleSheetFile";
|
|
191
|
+
"required": false;
|
|
192
|
+
"isSignal": true;
|
|
193
|
+
};
|
|
194
|
+
}, {
|
|
195
|
+
"printCompleted": "printCompleted";
|
|
196
|
+
}, never, never, true, never>;
|
|
197
|
+
}
|
|
198
|
+
export declare class NgxPrintModule {
|
|
199
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NgxPrintModule, never>;
|
|
200
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<NgxPrintModule, never, [typeof NgxPrintDirective], [typeof NgxPrintDirective]>;
|
|
201
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<NgxPrintModule>;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Service for handling printing functionality in Angular applications.
|
|
205
|
+
* Extends the base printing class (PrintBase).
|
|
206
|
+
*
|
|
207
|
+
* @export
|
|
208
|
+
* @class NgxPrintService
|
|
209
|
+
* @extends {PrintBase}
|
|
210
|
+
*/
|
|
211
|
+
export declare class NgxPrintService extends PrintBase {
|
|
212
|
+
/**
|
|
213
|
+
* Emits every time a print job completes.
|
|
214
|
+
*
|
|
215
|
+
* @deprecated The RxJS-based API will be removed in the next major version.
|
|
216
|
+
* Use the Promise returned by {@link NgxPrintService.print} instead, which resolves when that print job completes:
|
|
217
|
+
*
|
|
218
|
+
* ```ts
|
|
219
|
+
* // Before
|
|
220
|
+
* this.printService.printComplete$.pipe(take(1)).subscribe(() => onDone());
|
|
221
|
+
* this.printService.print(options);
|
|
222
|
+
*
|
|
223
|
+
* // After
|
|
224
|
+
* await this.printService.print(options);
|
|
225
|
+
* onDone();
|
|
226
|
+
* // or: this.printService.print(options).then(() => onDone());
|
|
227
|
+
* ```
|
|
228
|
+
*
|
|
229
|
+
* If you still need an Observable, wrap the Promise yourself: `from(this.printService.print(options))`.
|
|
230
|
+
*/
|
|
231
|
+
printComplete$: import("rxjs").Observable<void>;
|
|
232
|
+
/**
|
|
233
|
+
* Initiates the printing process using the provided print options.
|
|
234
|
+
*
|
|
235
|
+
* @param {PrintOptions} printOptions - Options for configuring the printing process.
|
|
236
|
+
* @memberof NgxPrintService
|
|
237
|
+
* @returns {Promise<void>} Resolves once this print job completes (the print dialog / window was closed).
|
|
238
|
+
* It cannot tell whether the user printed or cancelled, and it never settles if printing
|
|
239
|
+
* could not be started (e.g. blocked popup, missing print section).
|
|
240
|
+
*/
|
|
241
|
+
print(printOptions?: Partial<PrintOptions>): Promise<void>;
|
|
242
|
+
/**
|
|
243
|
+
* Sets the print style for the printing process.
|
|
244
|
+
*
|
|
245
|
+
* @param values - Either a dictionary representing the print styles, or a raw CSS string.
|
|
246
|
+
* @memberof NgxPrintService
|
|
247
|
+
* @setter
|
|
248
|
+
*/
|
|
249
|
+
set printStyle(values: PrintStyleInput);
|
|
250
|
+
/**
|
|
251
|
+
* Sets the stylesheet file for the printing process.
|
|
252
|
+
*
|
|
253
|
+
* @param {string} cssList - A string representing the path to the stylesheet file.
|
|
254
|
+
* @memberof NgxPrintService
|
|
255
|
+
* @setter
|
|
256
|
+
*/
|
|
257
|
+
set styleSheetFile(cssList: string);
|
|
258
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NgxPrintService, never>;
|
|
259
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
260
|
+
}
|
|
261
|
+
export {};
|
|
262
|
+
//# sourceMappingURL=solidexpert-ngx-print.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solidexpert-ngx-print.d.ts","names":["i1.NgxPrintDirective"],"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":";;;;;qBAAa;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEY,YAAA,UAAU,QAAQ;;;;;;;YCDpB,aAAa,eAAe;;;;;YAM5B,kBAAkB;cAuBjB;UACH;UACA;UAEA;UACA;UACA;YACE,eAAa;;;;;;;YASb,cAAc,QAAQ;;;;;EAsBzB;;;;;;UAUC;;;;;;;YAWE,kBAAkB;UAgBpB;;;;;;;;UAyCA;;;;;;;;UA2BA;;;;;;;;UAqBA;;;;;;;;UAmBA;;;;;;;;;YAmBE,MAAM,mBAAmB,QAAQ,gBAAgB;;;;;UA0BnD;UAWA;UA6BA;UAoDA;UAeA;SA/UG,MAAA,GAAA,qBAAA;;;qBC3BA,0BAA0B;;;;WAI5B,qCAAW;WAEX,wCAAc;WAEd,oCAAU;WAEV,wCAAc;;;;WAKd,oCAAU;;;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