taxtank-core 2.0.64 → 2.0.66
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/fesm2022/taxtank-core.mjs +51 -23
- package/fesm2022/taxtank-core.mjs.map +1 -1
- package/index.d.ts +2 -1
- package/package.json +1 -1
|
@@ -41,7 +41,6 @@ import mixpanel from 'mixpanel-browser';
|
|
|
41
41
|
import { JwtHelperService } from '@auth0/angular-jwt';
|
|
42
42
|
import { jsPDF } from 'jspdf';
|
|
43
43
|
import { applyPlugin } from 'jspdf-autotable';
|
|
44
|
-
import html2pdf from 'html2pdf.js';
|
|
45
44
|
import * as xlsx from '@e965/xlsx';
|
|
46
45
|
import * as FileSaver from 'file-saver';
|
|
47
46
|
import * as i1$2 from '@angular/platform-browser';
|
|
@@ -20618,13 +20617,18 @@ class JsPdf extends jsPDF {
|
|
|
20618
20617
|
const FILE_SETTINGS$1 = {
|
|
20619
20618
|
margin: 10,
|
|
20620
20619
|
filename: 'export.pdf',
|
|
20620
|
+
image: { type: 'jpeg', quality: 0.8 },
|
|
20621
20621
|
html2canvas: {
|
|
20622
20622
|
scale: 2,
|
|
20623
|
+
windowWidth: 1000,
|
|
20624
|
+
windowHeight: 800,
|
|
20625
|
+
foreignObjectRendering: false,
|
|
20626
|
+
letterRendering: false,
|
|
20623
20627
|
useCORS: true,
|
|
20624
|
-
logging: true
|
|
20628
|
+
logging: true,
|
|
20625
20629
|
},
|
|
20626
20630
|
pagebreak: {
|
|
20627
|
-
mode: '
|
|
20631
|
+
mode: ''
|
|
20628
20632
|
},
|
|
20629
20633
|
jsPDF: {
|
|
20630
20634
|
unit: 'mm',
|
|
@@ -20643,43 +20647,67 @@ const FILE_SETTINGS$1 = {
|
|
|
20643
20647
|
*/
|
|
20644
20648
|
class PdfFromDomElementService {
|
|
20645
20649
|
init(elements, fileSettings) {
|
|
20646
|
-
const options = FILE_SETTINGS$1;
|
|
20650
|
+
const options = { ...FILE_SETTINGS$1 };
|
|
20647
20651
|
if (fileSettings) {
|
|
20648
20652
|
merge(options, fileSettings);
|
|
20649
20653
|
}
|
|
20650
20654
|
// HTML container in which the exported DOM elements will be placed
|
|
20651
|
-
const
|
|
20652
|
-
|
|
20655
|
+
const iframe = document.getElementById('iframe-pdf-export');
|
|
20656
|
+
const idoc = iframe.contentDocument;
|
|
20657
|
+
const htmlWrapper = idoc.getElementById('pdf-export');
|
|
20658
|
+
htmlWrapper.innerHTML = '';
|
|
20659
|
+
const scopeTokens = this.collectScopeTokens(elements);
|
|
20660
|
+
this.syncComponentStyles(idoc, scopeTokens);
|
|
20653
20661
|
elements.forEach((element) => {
|
|
20654
20662
|
htmlWrapper.append(element.cloneNode(true));
|
|
20655
20663
|
});
|
|
20664
|
+
idoc.body.offsetHeight;
|
|
20656
20665
|
// Set PDF options, save file and return result as Observable
|
|
20657
|
-
return html2pdf().from(htmlWrapper).set(options);
|
|
20666
|
+
return iframe.contentWindow.html2pdf().from(htmlWrapper).set(options);
|
|
20658
20667
|
}
|
|
20659
20668
|
download(elements, fileSettings) {
|
|
20660
|
-
return from(this.init(elements, fileSettings)
|
|
20661
|
-
.save());
|
|
20669
|
+
return from(this.init(elements, fileSettings).save());
|
|
20662
20670
|
}
|
|
20663
20671
|
export(elements, filename = FILE_SETTINGS$1.filename) {
|
|
20664
20672
|
return from(this.init(elements)
|
|
20665
20673
|
.outputPdf('blob')
|
|
20666
20674
|
.then((blob) => new File([blob], filename, { type: 'application/pdf' })));
|
|
20667
20675
|
}
|
|
20668
|
-
|
|
20669
|
-
|
|
20670
|
-
|
|
20671
|
-
|
|
20672
|
-
|
|
20673
|
-
|
|
20674
|
-
|
|
20675
|
-
|
|
20676
|
-
|
|
20677
|
-
|
|
20678
|
-
|
|
20679
|
-
|
|
20680
|
-
|
|
20681
|
-
|
|
20676
|
+
collectScopeTokens(elements) {
|
|
20677
|
+
const scopes = new Set();
|
|
20678
|
+
const grabFromElement = (el) => {
|
|
20679
|
+
Array.from(el.attributes).forEach(attr => {
|
|
20680
|
+
const name = attr.name;
|
|
20681
|
+
if (name.startsWith('_ngcontent-') || name.startsWith('_nghost-')) {
|
|
20682
|
+
scopes.add(name);
|
|
20683
|
+
}
|
|
20684
|
+
});
|
|
20685
|
+
};
|
|
20686
|
+
elements.forEach(el => {
|
|
20687
|
+
grabFromElement(el);
|
|
20688
|
+
el.querySelectorAll('*').forEach(child => grabFromElement(child));
|
|
20689
|
+
});
|
|
20690
|
+
return Array.from(scopes);
|
|
20691
|
+
}
|
|
20692
|
+
syncComponentStyles(idoc, scopeTokens) {
|
|
20693
|
+
idoc.head
|
|
20694
|
+
.querySelectorAll('style[data-pdf-component-style="1"]')
|
|
20695
|
+
.forEach(el => el.remove());
|
|
20696
|
+
if (!scopeTokens.length) {
|
|
20697
|
+
return;
|
|
20682
20698
|
}
|
|
20699
|
+
const parentDoc = document;
|
|
20700
|
+
const styleTags = parentDoc.head.querySelectorAll('style');
|
|
20701
|
+
styleTags.forEach(styleEl => {
|
|
20702
|
+
const cssText = styleEl.textContent || '';
|
|
20703
|
+
const matchesScope = scopeTokens.some(token => cssText.includes(token));
|
|
20704
|
+
if (!matchesScope) {
|
|
20705
|
+
return;
|
|
20706
|
+
}
|
|
20707
|
+
const clone = styleEl.cloneNode(true);
|
|
20708
|
+
clone.setAttribute('data-pdf-component-style', '1');
|
|
20709
|
+
idoc.head.appendChild(clone);
|
|
20710
|
+
});
|
|
20683
20711
|
}
|
|
20684
20712
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: PdfFromDomElementService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
20685
20713
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: PdfFromDomElementService, providedIn: 'root' }); }
|