@ngx-smz/core 21.2.2 → 21.3.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 +27 -0
- package/fesm2022/ngx-smz-core.mjs +6 -6
- package/fesm2022/ngx-smz-core.mjs.map +1 -1
- package/package.json +3 -3
- package/types/ngx-smz-core.d.ts +29 -1
package/README.md
CHANGED
|
@@ -26,6 +26,33 @@ ng build ngx-smz-ui
|
|
|
26
26
|
|
|
27
27
|
This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
|
|
28
28
|
|
|
29
|
+
## PDF export setup
|
|
30
|
+
|
|
31
|
+
`SmzDocumentBuilder` and `smz-document-viewer` use **`html2pdf.js`** and **`jspdf`** as **peer dependencies**. Install them in the host application:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install html2pdf.js@^0.14.0 jspdf@^4.2.0
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Do **not** add `html2pdf.bundle.js` to `angular.json` → `scripts`. The library imports `html2pdf.js` as an ES/CJS module; the Angular bundler resolves `html2canvas`, `jspdf`, and `dompurify` from `node_modules`.
|
|
38
|
+
|
|
39
|
+
If the build warns about CommonJS dependencies, add them to `allowedCommonJsDependencies` in `angular.json`:
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
[
|
|
43
|
+
"html2pdf.js",
|
|
44
|
+
"html2canvas",
|
|
45
|
+
"jspdf",
|
|
46
|
+
"dompurify",
|
|
47
|
+
"canvg",
|
|
48
|
+
"raf",
|
|
49
|
+
"core-js",
|
|
50
|
+
"rgbcolor"
|
|
51
|
+
]
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
See the **demos** app route `/document` for working examples of the `html2pdf` renderer.
|
|
55
|
+
|
|
29
56
|
### Publishing the Library
|
|
30
57
|
|
|
31
58
|
Once the project is built, you can publish your library by following these steps:
|
|
@@ -101,7 +101,7 @@ import { BadgeModule } from 'primeng/badge';
|
|
|
101
101
|
import Chart from 'chart.js/auto';
|
|
102
102
|
import { getRelativePosition } from 'chart.js/helpers';
|
|
103
103
|
import { jsPDF } from 'jspdf';
|
|
104
|
-
import
|
|
104
|
+
import html2pdf from 'html2pdf.js';
|
|
105
105
|
import sortBy$1 from 'lodash-es/sortBy';
|
|
106
106
|
import flatten$2 from 'lodash-es/flatten';
|
|
107
107
|
import * as i4$5 from 'primeng/picklist';
|
|
@@ -23872,7 +23872,6 @@ const SmzJsPdfUtils = {
|
|
|
23872
23872
|
};
|
|
23873
23873
|
|
|
23874
23874
|
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-return, @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type, @typescript-eslint/typedef, no-underscore-dangle, no-console, eqeqeq, @typescript-eslint/no-unused-vars, @typescript-eslint/no-useless-constructor, @typescript-eslint/explicit-member-accessibility, max-len, no-prototype-builtins, @typescript-eslint/no-shadow, @typescript-eslint/no-empty-object-type, no-var, no-case-declarations */
|
|
23875
|
-
window['html2canvas'] = html2canvas;
|
|
23876
23875
|
const INITIAL_ZOOM = 1;
|
|
23877
23876
|
class SmzDocumentsService {
|
|
23878
23877
|
store;
|
|
@@ -23929,17 +23928,18 @@ class SmzDocumentsService {
|
|
|
23929
23928
|
switch (state.renderer) {
|
|
23930
23929
|
case 'html2pdf':
|
|
23931
23930
|
// console.log('1 Document html2pdfOptions', state.export.html2pdfOptions);
|
|
23932
|
-
const
|
|
23931
|
+
const html2pdfWorker = html2pdf()
|
|
23933
23932
|
.from(element.nativeElement)
|
|
23934
23933
|
.set(state.export.html2pdfOptions)
|
|
23935
|
-
.toPdf()
|
|
23934
|
+
.toPdf();
|
|
23935
|
+
html2pdfWorker.get('pdf').then((pdf) => {
|
|
23936
23936
|
if (state.summary.showPageNumbers) {
|
|
23937
23937
|
SmzJsPdfUtils.addPageNumbers(pdf, state);
|
|
23938
23938
|
}
|
|
23939
23939
|
});
|
|
23940
23940
|
switch (action) {
|
|
23941
23941
|
case 'open': {
|
|
23942
|
-
|
|
23942
|
+
html2pdfWorker.outputPdf()
|
|
23943
23943
|
.then((pdf) => {
|
|
23944
23944
|
const base64Pdf = btoa(pdf);
|
|
23945
23945
|
window.open(base64Pdf, '_blank');
|
|
@@ -23949,7 +23949,7 @@ class SmzDocumentsService {
|
|
|
23949
23949
|
}
|
|
23950
23950
|
// case 'print': this.pdfMakeService.pdfMake.createPdf(document).print(); break;
|
|
23951
23951
|
case 'download': {
|
|
23952
|
-
|
|
23952
|
+
html2pdfWorker.save()
|
|
23953
23953
|
.then(() => { resolve('Resolved'); });
|
|
23954
23954
|
break;
|
|
23955
23955
|
}
|