ngx-print 1.3.1 → 1.5.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 +78 -1
- package/esm2022/lib/ngx-print.base.mjs +193 -0
- package/esm2022/lib/ngx-print.directive.mjs +115 -0
- package/esm2022/lib/ngx-print.module.mjs +16 -0
- package/esm2022/lib/ngx-print.service.mjs +53 -0
- package/esm2022/lib/print-options.mjs +15 -0
- package/{esm2020 → esm2022}/ngx-print.mjs +4 -4
- package/esm2022/public_api.mjs +8 -0
- package/fesm2022/ngx-print.mjs +393 -0
- package/fesm2022/ngx-print.mjs.map +1 -0
- package/index.d.ts +5 -5
- package/lib/ngx-print.base.d.ts +86 -0
- package/lib/ngx-print.base.d.ts.map +1 -0
- package/lib/ngx-print.directive.d.ts +68 -94
- package/lib/ngx-print.directive.d.ts.map +1 -1
- package/lib/ngx-print.module.d.ts +7 -7
- package/lib/ngx-print.module.d.ts.map +1 -1
- package/lib/ngx-print.service.d.ts +44 -0
- package/lib/ngx-print.service.d.ts.map +1 -0
- package/lib/print-options.d.ts +11 -0
- package/lib/print-options.d.ts.map +1 -0
- package/package.json +5 -11
- package/public_api.d.ts +4 -2
- package/public_api.d.ts.map +1 -1
- package/esm2020/lib/ngx-print.directive.mjs +0 -187
- package/esm2020/lib/ngx-print.module.mjs +0 -17
- package/esm2020/public_api.mjs +0 -6
- package/fesm2015/ngx-print.mjs +0 -212
- package/fesm2015/ngx-print.mjs.map +0 -1
- package/fesm2020/ngx-print.mjs +0 -212
- package/fesm2020/ngx-print.mjs.map +0 -1
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable, Directive, Input, HostListener, NgModule } from '@angular/core';
|
|
3
|
+
|
|
4
|
+
class PrintBase {
|
|
5
|
+
_printStyle = [];
|
|
6
|
+
_styleSheetFile = '';
|
|
7
|
+
//#region Getters and Setters
|
|
8
|
+
/**
|
|
9
|
+
* Sets the print styles based on the provided values.
|
|
10
|
+
*
|
|
11
|
+
* @param {Object} values - Key-value pairs representing print styles.
|
|
12
|
+
* @protected
|
|
13
|
+
*/
|
|
14
|
+
setPrintStyle(values) {
|
|
15
|
+
this._printStyle = [];
|
|
16
|
+
for (let key in values) {
|
|
17
|
+
if (values.hasOwnProperty(key)) {
|
|
18
|
+
this._printStyle.push((key + JSON.stringify(values[key])).replace(/['"]+/g, ''));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
*
|
|
25
|
+
* @returns the string that create the stylesheet which will be injected
|
|
26
|
+
* later within <style></style> tag.
|
|
27
|
+
*
|
|
28
|
+
* -join/replace to transform an array objects to css-styled string
|
|
29
|
+
*/
|
|
30
|
+
returnStyleValues() {
|
|
31
|
+
return `<style> ${this._printStyle.join(' ').replace(/,/g, ';')} </style>`;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @returns string which contains the link tags containing the css which will
|
|
35
|
+
* be injected later within <head></head> tag.
|
|
36
|
+
*
|
|
37
|
+
*/
|
|
38
|
+
returnStyleSheetLinkTags() {
|
|
39
|
+
return this._styleSheetFile;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Sets the style sheet file based on the provided CSS list.
|
|
43
|
+
*
|
|
44
|
+
* @param {string} cssList - CSS file or list of CSS files.
|
|
45
|
+
* @protected
|
|
46
|
+
*/
|
|
47
|
+
setStyleSheetFile(cssList) {
|
|
48
|
+
let linkTagFn = function (cssFileName) {
|
|
49
|
+
return `<link rel="stylesheet" type="text/css" href="${cssFileName}">`;
|
|
50
|
+
};
|
|
51
|
+
if (cssList.indexOf(',') !== -1) {
|
|
52
|
+
const valueArr = cssList.split(',');
|
|
53
|
+
this._styleSheetFile = valueArr.map(val => linkTagFn(val)).join('');
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
this._styleSheetFile = linkTagFn(cssList);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region Private methods used by PrintBase
|
|
61
|
+
/**
|
|
62
|
+
* Updates the default values for input elements.
|
|
63
|
+
*
|
|
64
|
+
* @param {HTMLCollectionOf<HTMLInputElement>} elements - Collection of input elements.
|
|
65
|
+
* @private
|
|
66
|
+
*/
|
|
67
|
+
updateInputDefaults(elements) {
|
|
68
|
+
for (let i = 0; i < elements.length; i++) {
|
|
69
|
+
const element = elements[i];
|
|
70
|
+
element['defaultValue'] = element.value;
|
|
71
|
+
if (element['checked'])
|
|
72
|
+
element['defaultChecked'] = true;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Updates the default values for select elements.
|
|
77
|
+
*
|
|
78
|
+
* @param {HTMLCollectionOf<HTMLSelectElement>} elements - Collection of select elements.
|
|
79
|
+
* @private
|
|
80
|
+
*/
|
|
81
|
+
updateSelectDefaults(elements) {
|
|
82
|
+
for (let i = 0; i < elements.length; i++) {
|
|
83
|
+
const element = elements[i];
|
|
84
|
+
const selectedIdx = element.selectedIndex;
|
|
85
|
+
const selectedOption = element.options[selectedIdx];
|
|
86
|
+
selectedOption.defaultSelected = true;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Updates the default values for textarea elements.
|
|
91
|
+
*
|
|
92
|
+
* @param {HTMLCollectionOf<HTMLTextAreaElement>} elements - Collection of textarea elements.
|
|
93
|
+
* @private
|
|
94
|
+
*/
|
|
95
|
+
updateTextAreaDefaults(elements) {
|
|
96
|
+
for (let i = 0; i < elements.length; i++) {
|
|
97
|
+
const element = elements[i];
|
|
98
|
+
element['defaultValue'] = element.value;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Retrieves the HTML content of a specified printing section.
|
|
103
|
+
*
|
|
104
|
+
* @param {string} printSectionId - Id of the printing section.
|
|
105
|
+
* @returns {string | null} - HTML content of the printing section, or null if not found.
|
|
106
|
+
* @private
|
|
107
|
+
*/
|
|
108
|
+
getHtmlContents(printSectionId) {
|
|
109
|
+
const printContents = document.getElementById(printSectionId);
|
|
110
|
+
if (!printContents)
|
|
111
|
+
return null;
|
|
112
|
+
const inputEls = printContents.getElementsByTagName('input');
|
|
113
|
+
const selectEls = printContents.getElementsByTagName('select');
|
|
114
|
+
const textAreaEls = printContents.getElementsByTagName('textarea');
|
|
115
|
+
this.updateInputDefaults(inputEls);
|
|
116
|
+
this.updateSelectDefaults(selectEls);
|
|
117
|
+
this.updateTextAreaDefaults(textAreaEls);
|
|
118
|
+
return printContents.innerHTML;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Retrieves the HTML content of elements with the specified tag.
|
|
122
|
+
*
|
|
123
|
+
* @param {keyof HTMLElementTagNameMap} tag - HTML tag name.
|
|
124
|
+
* @returns {string} - Concatenated outerHTML of elements with the specified tag.
|
|
125
|
+
* @private
|
|
126
|
+
*/
|
|
127
|
+
getElementTag(tag) {
|
|
128
|
+
const html = [];
|
|
129
|
+
const elements = document.getElementsByTagName(tag);
|
|
130
|
+
for (let index = 0; index < elements.length; index++) {
|
|
131
|
+
html.push(elements[index].outerHTML);
|
|
132
|
+
}
|
|
133
|
+
return html.join('\r\n');
|
|
134
|
+
}
|
|
135
|
+
//#endregion
|
|
136
|
+
/**
|
|
137
|
+
* Prints the specified content using the provided print options.
|
|
138
|
+
*
|
|
139
|
+
* @param {PrintOptions} printOptions - Options for printing.
|
|
140
|
+
* @public
|
|
141
|
+
*/
|
|
142
|
+
print(printOptions) {
|
|
143
|
+
let styles = '', links = '';
|
|
144
|
+
const baseTag = this.getElementTag('base');
|
|
145
|
+
if (printOptions.useExistingCss) {
|
|
146
|
+
styles = this.getElementTag('style');
|
|
147
|
+
links = this.getElementTag('link');
|
|
148
|
+
}
|
|
149
|
+
const printContents = this.getHtmlContents(printOptions.printSectionId);
|
|
150
|
+
if (!printContents) {
|
|
151
|
+
// Handle the case where the specified print section is not found.
|
|
152
|
+
console.error(`Print section with id ${printOptions.printSectionId} not found.`);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const popupWin = window.open("", "_blank", "top=0,left=0,height=auto,width=auto");
|
|
156
|
+
popupWin.document.open();
|
|
157
|
+
popupWin.document.write(`
|
|
158
|
+
<html>
|
|
159
|
+
<head>
|
|
160
|
+
<title>${printOptions.printTitle ? printOptions.printTitle : ""}</title>
|
|
161
|
+
${baseTag}
|
|
162
|
+
${this.returnStyleValues()}
|
|
163
|
+
${this.returnStyleSheetLinkTags()}
|
|
164
|
+
${styles}
|
|
165
|
+
${links}
|
|
166
|
+
</head>
|
|
167
|
+
<body ${printOptions.bodyClass ? `class="${printOptions.bodyClass}"` : ''}>
|
|
168
|
+
${printContents}
|
|
169
|
+
<script defer>
|
|
170
|
+
function triggerPrint(event) {
|
|
171
|
+
window.removeEventListener('load', triggerPrint, false);
|
|
172
|
+
${printOptions.previewOnly ? '' : `setTimeout(function() {
|
|
173
|
+
closeWindow(window.print());
|
|
174
|
+
}, ${printOptions.printDelay});`}
|
|
175
|
+
}
|
|
176
|
+
function closeWindow(){
|
|
177
|
+
${printOptions.closeWindow ? 'window.close();' : ''}
|
|
178
|
+
}
|
|
179
|
+
window.addEventListener('load', triggerPrint, false);
|
|
180
|
+
</script>
|
|
181
|
+
</body>
|
|
182
|
+
</html>`);
|
|
183
|
+
popupWin.document.close();
|
|
184
|
+
}
|
|
185
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: PrintBase, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
186
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: PrintBase, providedIn: 'root' });
|
|
187
|
+
}
|
|
188
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: PrintBase, decorators: [{
|
|
189
|
+
type: Injectable,
|
|
190
|
+
args: [{
|
|
191
|
+
providedIn: 'root'
|
|
192
|
+
}]
|
|
193
|
+
}] });
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Service for handling printing functionality in Angular applications.
|
|
197
|
+
* Extends the base printing class (PrintBase).
|
|
198
|
+
*
|
|
199
|
+
* @export
|
|
200
|
+
* @class NgxPrintService
|
|
201
|
+
* @extends {PrintBase}
|
|
202
|
+
*/
|
|
203
|
+
class NgxPrintService extends PrintBase {
|
|
204
|
+
/**
|
|
205
|
+
* Initiates the printing process using the provided print options.
|
|
206
|
+
*
|
|
207
|
+
* @param {PrintOptions} printOptions - Options for configuring the printing process.
|
|
208
|
+
* @memberof NgxPrintService
|
|
209
|
+
* @returns {void}
|
|
210
|
+
*/
|
|
211
|
+
print(printOptions) {
|
|
212
|
+
// Call the print method in the parent class
|
|
213
|
+
super.print(printOptions);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Sets the print style for the printing process.
|
|
217
|
+
*
|
|
218
|
+
* @param {{ [key: string]: { [key: string]: string } }} values - A dictionary representing the print styles.
|
|
219
|
+
* @memberof NgxPrintService
|
|
220
|
+
* @setter
|
|
221
|
+
*/
|
|
222
|
+
set printStyle(values) {
|
|
223
|
+
super.setPrintStyle(values);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Sets the stylesheet file for the printing process.
|
|
227
|
+
*
|
|
228
|
+
* @param {string} cssList - A string representing the path to the stylesheet file.
|
|
229
|
+
* @memberof NgxPrintService
|
|
230
|
+
* @setter
|
|
231
|
+
*/
|
|
232
|
+
set styleSheetFile(cssList) {
|
|
233
|
+
super.setStyleSheetFile(cssList);
|
|
234
|
+
}
|
|
235
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: NgxPrintService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
236
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: NgxPrintService, providedIn: "root" });
|
|
237
|
+
}
|
|
238
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: NgxPrintService, decorators: [{
|
|
239
|
+
type: Injectable,
|
|
240
|
+
args: [{
|
|
241
|
+
providedIn: "root",
|
|
242
|
+
}]
|
|
243
|
+
}] });
|
|
244
|
+
|
|
245
|
+
class PrintOptions {
|
|
246
|
+
printSectionId = null;
|
|
247
|
+
printTitle = null;
|
|
248
|
+
useExistingCss = false;
|
|
249
|
+
bodyClass = '';
|
|
250
|
+
previewOnly = false;
|
|
251
|
+
closeWindow = true;
|
|
252
|
+
printDelay = 0;
|
|
253
|
+
constructor(options) {
|
|
254
|
+
if (options) {
|
|
255
|
+
Object.assign(this, options);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
class NgxPrintDirective extends PrintBase {
|
|
261
|
+
printOptions = new PrintOptions();
|
|
262
|
+
/**
|
|
263
|
+
* Prevents the print dialog from opening on the window
|
|
264
|
+
*
|
|
265
|
+
* @memberof NgxPrintDirective
|
|
266
|
+
*/
|
|
267
|
+
set previewOnly(value) {
|
|
268
|
+
this.printOptions = { ...this.printOptions, previewOnly: value };
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
*
|
|
272
|
+
*
|
|
273
|
+
* @memberof NgxPrintDirective
|
|
274
|
+
*/
|
|
275
|
+
set printSectionId(value) {
|
|
276
|
+
this.printOptions = { ...this.printOptions, printSectionId: value };
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
*
|
|
280
|
+
*
|
|
281
|
+
* @memberof NgxPrintDirective
|
|
282
|
+
*/
|
|
283
|
+
set printTitle(value) {
|
|
284
|
+
this.printOptions = { ...this.printOptions, printSectionId: value };
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
*
|
|
288
|
+
*
|
|
289
|
+
* @memberof NgxPrintDirective
|
|
290
|
+
*/
|
|
291
|
+
set useExistingCss(value) {
|
|
292
|
+
this.printOptions = { ...this.printOptions, useExistingCss: value };
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* A delay in milliseconds to force the print dialog to wait before opened. Default: 0
|
|
296
|
+
*
|
|
297
|
+
* @memberof NgxPrintDirective
|
|
298
|
+
*/
|
|
299
|
+
set printDelay(value) {
|
|
300
|
+
this.printOptions = { ...this.printOptions, printDelay: value };
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Whether to close the window after print() returns.
|
|
304
|
+
*
|
|
305
|
+
*/
|
|
306
|
+
set closeWindow(value) {
|
|
307
|
+
this.printOptions = { ...this.printOptions, closeWindow: value };
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Class attribute to apply to the body element.
|
|
311
|
+
*
|
|
312
|
+
*/
|
|
313
|
+
set bodyClass(value) {
|
|
314
|
+
this.printOptions = { ...this.printOptions, bodyClass: value };
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
*
|
|
318
|
+
*
|
|
319
|
+
* @memberof NgxPrintDirective
|
|
320
|
+
*/
|
|
321
|
+
set printStyle(values) {
|
|
322
|
+
super.setPrintStyle(values);
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* @memberof NgxPrintDirective
|
|
326
|
+
* @param cssList
|
|
327
|
+
*/
|
|
328
|
+
set styleSheetFile(cssList) {
|
|
329
|
+
super.setStyleSheetFile(cssList);
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
*
|
|
333
|
+
*
|
|
334
|
+
* @memberof NgxPrintDirective
|
|
335
|
+
*/
|
|
336
|
+
print() {
|
|
337
|
+
super.print(this.printOptions);
|
|
338
|
+
}
|
|
339
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: NgxPrintDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
340
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.0.4", type: NgxPrintDirective, isStandalone: true, selector: "button[ngxPrint]", inputs: { previewOnly: "previewOnly", printSectionId: "printSectionId", printTitle: "printTitle", useExistingCss: "useExistingCss", printDelay: "printDelay", closeWindow: "closeWindow", bodyClass: "bodyClass", printStyle: "printStyle", styleSheetFile: "styleSheetFile" }, host: { listeners: { "click": "print()" } }, usesInheritance: true, ngImport: i0 });
|
|
341
|
+
}
|
|
342
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: NgxPrintDirective, decorators: [{
|
|
343
|
+
type: Directive,
|
|
344
|
+
args: [{
|
|
345
|
+
selector: "button[ngxPrint]",
|
|
346
|
+
standalone: true
|
|
347
|
+
}]
|
|
348
|
+
}], propDecorators: { previewOnly: [{
|
|
349
|
+
type: Input
|
|
350
|
+
}], printSectionId: [{
|
|
351
|
+
type: Input
|
|
352
|
+
}], printTitle: [{
|
|
353
|
+
type: Input
|
|
354
|
+
}], useExistingCss: [{
|
|
355
|
+
type: Input
|
|
356
|
+
}], printDelay: [{
|
|
357
|
+
type: Input
|
|
358
|
+
}], closeWindow: [{
|
|
359
|
+
type: Input
|
|
360
|
+
}], bodyClass: [{
|
|
361
|
+
type: Input
|
|
362
|
+
}], printStyle: [{
|
|
363
|
+
type: Input
|
|
364
|
+
}], styleSheetFile: [{
|
|
365
|
+
type: Input
|
|
366
|
+
}], print: [{
|
|
367
|
+
type: HostListener,
|
|
368
|
+
args: ['click']
|
|
369
|
+
}] } });
|
|
370
|
+
|
|
371
|
+
class NgxPrintModule {
|
|
372
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: NgxPrintModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
373
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.4", ngImport: i0, type: NgxPrintModule, imports: [NgxPrintDirective], exports: [NgxPrintDirective] });
|
|
374
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: NgxPrintModule });
|
|
375
|
+
}
|
|
376
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: NgxPrintModule, decorators: [{
|
|
377
|
+
type: NgModule,
|
|
378
|
+
args: [{
|
|
379
|
+
imports: [NgxPrintDirective],
|
|
380
|
+
exports: [NgxPrintDirective]
|
|
381
|
+
}]
|
|
382
|
+
}] });
|
|
383
|
+
|
|
384
|
+
/*
|
|
385
|
+
* Public API Surface of ngx-print
|
|
386
|
+
*/
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Generated bundle index. Do not edit.
|
|
390
|
+
*/
|
|
391
|
+
|
|
392
|
+
export { NgxPrintDirective, NgxPrintModule, NgxPrintService, PrintOptions };
|
|
393
|
+
//# sourceMappingURL=ngx-print.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngx-print.mjs","sources":["../../../src/lib/ngx-print.base.ts","../../../src/lib/ngx-print.service.ts","../../../src/lib/print-options.ts","../../../src/lib/ngx-print.directive.ts","../../../src/lib/ngx-print.module.ts","../../../src/public_api.ts","../../../src/ngx-print.ts"],"sourcesContent":["import { Injectable } from \"@angular/core\";\r\nimport { PrintOptions } from \"./print-options\";\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class PrintBase {\r\n\r\n private _printStyle: string[] = [];\r\n private _styleSheetFile: string = '';\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 (let key in values) {\r\n if (values.hasOwnProperty(key)) {\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 *\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 return `<style> ${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 let linkTagFn = function (cssFileName) {\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 (let i = 0; i < elements.length; i++) {\r\n const element = elements[i];\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 (let i = 0; i < elements.length; i++) {\r\n const element = elements[i];\r\n const selectedIdx = element.selectedIndex;\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 (let i = 0; i < elements.length; i++) {\r\n const element = elements[i];\r\n element['defaultValue'] = element.value;\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\r\n this.updateInputDefaults(inputEls);\r\n this.updateSelectDefaults(selectEls);\r\n this.updateTextAreaDefaults(textAreaEls);\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 //#endregion\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\r\n let styles = '', 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 if (!printContents) {\r\n // Handle the case where the specified print section is not found.\r\n console.error(`Print section with id ${printOptions.printSectionId} not found.`);\r\n return;\r\n }\r\n\r\n const popupWin = window.open(\"\", \"_blank\", \"top=0,left=0,height=auto,width=auto\");\r\n popupWin.document.open();\r\n popupWin.document.write(`\r\n <html>\r\n <head>\r\n <title>${printOptions.printTitle ? printOptions.printTitle : \"\"}</title>\r\n ${baseTag}\r\n ${this.returnStyleValues()}\r\n ${this.returnStyleSheetLinkTags()}\r\n ${styles}\r\n ${links}\r\n </head>\r\n <body ${printOptions.bodyClass ? `class=\"${printOptions.bodyClass}\"` : ''}>\r\n ${printContents}\r\n <script defer>\r\n function triggerPrint(event) {\r\n window.removeEventListener('load', triggerPrint, false);\r\n ${printOptions.previewOnly ? '' : `setTimeout(function() {\r\n closeWindow(window.print());\r\n }, ${printOptions.printDelay});`}\r\n }\r\n function closeWindow(){\r\n ${printOptions.closeWindow ? 'window.close();' : ''}\r\n }\r\n window.addEventListener('load', triggerPrint, false);\r\n </script>\r\n </body>\r\n </html>`);\r\n popupWin.document.close();\r\n }\r\n}\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\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 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 /**\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","export class PrintOptions {\r\n printSectionId: string = null;\r\n printTitle: string = null;\r\n useExistingCss: boolean = false;\r\n bodyClass: string = '';\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 } from '@angular/core';\r\nimport { PrintBase } from './ngx-print.base';\r\nimport { PrintOptions } from './print-options';\r\n@Directive({\r\n selector: \"button[ngxPrint]\",\r\n standalone: true\r\n})\r\nexport class NgxPrintDirective extends PrintBase {\r\n private printOptions = new PrintOptions();\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, printSectionId: 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 *\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 /**\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 print(): void {\r\n super.print(this.printOptions);\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","/*\r\n * Public API Surface of ngx-print\r\n */\r\nexport * from './lib/ngx-print.service';\r\nexport * from './lib/ngx-print.directive';\r\nexport * from './lib/ngx-print.module';\r\nexport * from './lib/print-options';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;MAMa,SAAS,CAAA;IAEV,WAAW,GAAa,EAAE,CAAC;IAC3B,eAAe,GAAW,EAAE,CAAC;;AAGrC;;;;;AAKG;AACO,IAAA,aAAa,CAAC,MAAoD,EAAA;AACxE,QAAA,IAAI,CAAC,WAAW,GAAG,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KAAK;gBASO,cAAc,EAAA,CAAA;sBAA1B,KAAK;gBASO,UAAU,EAAA,CAAA;sBAAtB,KAAK;gBASO,cAAc,EAAA,CAAA;sBAA1B,KAAK;gBASO,UAAU,EAAA,CAAA;sBAAtB,KAAK;gBAQO,WAAW,EAAA,CAAA;sBAAvB,KAAK;gBAQO,SAAS,EAAA,CAAA;sBAArB,KAAK;gBAUF,UAAU,EAAA,CAAA;sBADb,KAAK;gBAWF,cAAc,EAAA,CAAA;sBADjB,KAAK;gBAWC,KAAK,EAAA,CAAA;sBADX,YAAY;uBAAC,OAAO,CAAA;;;MCxFV,cAAc,CAAA;uGAAd,cAAc,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;wGAAd,cAAc,EAAA,OAAA,EAAA,CAHf,iBAAiB,CAAA,EAAA,OAAA,EAAA,CACjB,iBAAiB,CAAA,EAAA,CAAA,CAAA;wGAEhB,cAAc,EAAA,CAAA,CAAA;;2FAAd,cAAc,EAAA,UAAA,EAAA,CAAA;kBAJ1B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACR,OAAO,EAAE,CAAC,iBAAiB,CAAC;oBAC5B,OAAO,EAAE,CAAC,iBAAiB,CAAC;AAC7B,iBAAA,CAAA;;;ACND;;AAEG;;ACFH;;AAEG;;;;"}
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generated bundle index. Do not edit.
|
|
3
|
-
*/
|
|
4
|
-
/// <amd-module name="ngx-print" />
|
|
5
|
-
export * from './public_api';
|
|
1
|
+
/**
|
|
2
|
+
* Generated bundle index. Do not edit.
|
|
3
|
+
*/
|
|
4
|
+
/// <amd-module name="ngx-print" />
|
|
5
|
+
export * from './public_api';
|
|
6
6
|
//# sourceMappingURL=ngx-print.d.ts.map
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { PrintOptions } from "./print-options";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export declare class PrintBase {
|
|
4
|
+
private _printStyle;
|
|
5
|
+
private _styleSheetFile;
|
|
6
|
+
/**
|
|
7
|
+
* Sets the print styles based on the provided values.
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} values - Key-value pairs representing print styles.
|
|
10
|
+
* @protected
|
|
11
|
+
*/
|
|
12
|
+
protected setPrintStyle(values: {
|
|
13
|
+
[key: string]: {
|
|
14
|
+
[key: string]: string;
|
|
15
|
+
};
|
|
16
|
+
}): void;
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
*
|
|
20
|
+
* @returns the string that create the stylesheet which will be injected
|
|
21
|
+
* later within <style></style> tag.
|
|
22
|
+
*
|
|
23
|
+
* -join/replace to transform an array objects to css-styled string
|
|
24
|
+
*/
|
|
25
|
+
returnStyleValues(): string;
|
|
26
|
+
/**
|
|
27
|
+
* @returns string which contains the link tags containing the css which will
|
|
28
|
+
* be injected later within <head></head> tag.
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
private returnStyleSheetLinkTags;
|
|
32
|
+
/**
|
|
33
|
+
* Sets the style sheet file based on the provided CSS list.
|
|
34
|
+
*
|
|
35
|
+
* @param {string} cssList - CSS file or list of CSS files.
|
|
36
|
+
* @protected
|
|
37
|
+
*/
|
|
38
|
+
protected setStyleSheetFile(cssList: string): void;
|
|
39
|
+
/**
|
|
40
|
+
* Updates the default values for input elements.
|
|
41
|
+
*
|
|
42
|
+
* @param {HTMLCollectionOf<HTMLInputElement>} elements - Collection of input elements.
|
|
43
|
+
* @private
|
|
44
|
+
*/
|
|
45
|
+
private updateInputDefaults;
|
|
46
|
+
/**
|
|
47
|
+
* Updates the default values for select elements.
|
|
48
|
+
*
|
|
49
|
+
* @param {HTMLCollectionOf<HTMLSelectElement>} elements - Collection of select elements.
|
|
50
|
+
* @private
|
|
51
|
+
*/
|
|
52
|
+
private updateSelectDefaults;
|
|
53
|
+
/**
|
|
54
|
+
* Updates the default values for textarea elements.
|
|
55
|
+
*
|
|
56
|
+
* @param {HTMLCollectionOf<HTMLTextAreaElement>} elements - Collection of textarea elements.
|
|
57
|
+
* @private
|
|
58
|
+
*/
|
|
59
|
+
private updateTextAreaDefaults;
|
|
60
|
+
/**
|
|
61
|
+
* Retrieves the HTML content of a specified printing section.
|
|
62
|
+
*
|
|
63
|
+
* @param {string} printSectionId - Id of the printing section.
|
|
64
|
+
* @returns {string | null} - HTML content of the printing section, or null if not found.
|
|
65
|
+
* @private
|
|
66
|
+
*/
|
|
67
|
+
private getHtmlContents;
|
|
68
|
+
/**
|
|
69
|
+
* Retrieves the HTML content of elements with the specified tag.
|
|
70
|
+
*
|
|
71
|
+
* @param {keyof HTMLElementTagNameMap} tag - HTML tag name.
|
|
72
|
+
* @returns {string} - Concatenated outerHTML of elements with the specified tag.
|
|
73
|
+
* @private
|
|
74
|
+
*/
|
|
75
|
+
private getElementTag;
|
|
76
|
+
/**
|
|
77
|
+
* Prints the specified content using the provided print options.
|
|
78
|
+
*
|
|
79
|
+
* @param {PrintOptions} printOptions - Options for printing.
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
82
|
+
protected print(printOptions: PrintOptions): void;
|
|
83
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<PrintBase, never>;
|
|
84
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<PrintBase>;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=ngx-print.base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngx-print.base.d.ts","sourceRoot":"","sources":["../../../src/lib/ngx-print.base.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;;AAE/C,qBAGa,SAAS;IAElB,OAAO,CAAC,WAAW,CAAgB;IACnC,OAAO,CAAC,eAAe,CAAc;IAGrC;;;;;OAKG;IACH,SAAS,CAAC,aAAa,CAAC,MAAM,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;SAAE,CAAA;KAAE;IAS5E;;;;;;;OAOG;IACI,iBAAiB;IAIxB;;;;KAIC;IACD,OAAO,CAAC,wBAAwB;IAIhC;;;;;OAKG;IACH,SAAS,CAAC,iBAAiB,CAAC,OAAO,EAAE,MAAM;IAiB3C;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;IAQ3B;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IAU5B;;;;;OAKG;IACH,OAAO,CAAC,sBAAsB;IAO9B;;;;;;OAMG;IACH,OAAO,CAAC,eAAe;IAevB;;;;;;OAMG;IACH,OAAO,CAAC,aAAa;IAWrB;;;;;OAKG;IACH,SAAS,CAAC,KAAK,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI;yCA1JxC,SAAS;6CAAT,SAAS;CAyMrB"}
|