taxtank-core 2.0.58 → 2.0.59

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.
@@ -20647,75 +20647,30 @@ const FILE_SETTINGS$1 = {
20647
20647
  * in which all the styles that the user sees on the page will be saved
20648
20648
  */
20649
20649
  class PdfFromDomElementService {
20650
- createIsolatedDocument(elements) {
20651
- // Создаём скрытый iframe, чтобы клонер html2canvas не копировал всю SPA
20652
- const iframe = document.createElement('iframe');
20653
- Object.assign(iframe.style, {
20654
- position: 'fixed',
20655
- left: '-99999px',
20656
- top: '0',
20657
- width: '1200px',
20658
- height: '900px',
20659
- visibility: 'hidden'
20660
- });
20661
- document.body.appendChild(iframe);
20662
- const idoc = iframe.contentDocument;
20663
- idoc.open();
20664
- idoc.write(`
20665
- <!doctype html>
20666
- <html>
20667
- <head>
20668
- <meta charset="utf-8"/>
20669
- <style>
20670
- body{margin:0;background:#fff;font-family:Arial,Helvetica,sans-serif;}
20671
- .pdf-export input.mat-mdc-input-element{
20672
- height:30px;margin-top:20px;padding:0 15px;
20673
- }
20674
- </style>
20675
- </head>
20676
- <body><div id="pdf-root"></div></body>
20677
- </html>
20678
- `);
20679
- idoc.close();
20680
- const pdfRoot = idoc.getElementById('pdf-root');
20681
- elements.forEach((el) => pdfRoot.append(el.cloneNode(true)));
20682
- // await (idoc as any).fonts?.ready?.catch(() => {});
20683
- // await Promise.all(
20684
- // Array.from(pdfRoot.querySelectorAll('img')).map(img => img.decode?.().catch(() => {}))
20685
- // );
20686
- return pdfRoot;
20687
- }
20688
20650
  init(elements, fileSettings) {
20689
20651
  const options = FILE_SETTINGS$1;
20690
20652
  if (fileSettings) {
20691
20653
  merge(options, fileSettings);
20692
20654
  }
20693
20655
  // HTML container in which the exported DOM elements will be placed
20694
- const htmlWrapper = document.createElement('div');
20656
+ // const htmlWrapper: HTMLElement = document.createElement('div');
20657
+ const htmlWrapper = document.getElementById('iframe-pdf-export').contentDocument.getElementById('htmltopdf-export');
20695
20658
  this.injectExportStyles(htmlWrapper);
20696
20659
  elements.forEach((element) => {
20697
20660
  htmlWrapper.append(element.cloneNode(true));
20698
20661
  });
20699
- const pdfRoot = this.createIsolatedDocument(elements);
20700
20662
  // Set PDF options, save file and return result as Observable
20701
- return html2pdf().from(pdfRoot).set(options);
20663
+ return html2pdf().from(htmlWrapper).set(options);
20702
20664
  }
20703
20665
  download(elements, fileSettings) {
20704
- const start = new Date();
20705
20666
  return from(this.init(elements, fileSettings)
20706
20667
  .save()
20707
- .then(() => {
20708
- console.log((new Date().getTime() - start.getTime()) / 1000);
20709
- }));
20668
+ .then());
20710
20669
  }
20711
20670
  export(elements, filename = FILE_SETTINGS$1.filename) {
20712
- const start = new Date();
20713
20671
  return from(this.init(elements)
20714
20672
  .outputPdf('blob')
20715
- .then((blob) => {
20716
- console.log((new Date().getTime() - start.getTime()) / 1000);
20717
- return new File([blob], filename, { type: 'application/pdf' });
20718
- }));
20673
+ .then((blob) => new File([blob], filename, { type: 'application/pdf' })));
20719
20674
  }
20720
20675
  // fix html2canvas-pro problem with vertical alignment: https://github.com/yorickshan/html2canvas-pro/issues/92
20721
20676
  injectExportStyles(element) {