@design.estate/dees-document 1.6.9 → 2.0.3

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.
Files changed (110) hide show
  1. package/dist_bundle/bundle.js +622 -605
  2. package/dist_bundle/bundle.js.map +4 -4
  3. package/dist_ts/00_commitinfo_data.js +1 -1
  4. package/dist_ts/classes.pdfservice.d.ts +3 -3
  5. package/dist_ts/classes.pdfservice.js +6 -3
  6. package/dist_ts/helpers.d.ts +1 -1
  7. package/dist_ts/helpers.js +2 -2
  8. package/dist_ts/paths.js +4 -2
  9. package/dist_ts/plugins.d.ts +2 -0
  10. package/dist_ts/plugins.js +3 -1
  11. package/dist_ts_shared/demoletter.d.ts +3 -3
  12. package/dist_ts_shared/demoletter.js +223 -192
  13. package/dist_ts_shared/index.d.ts +6 -7
  14. package/dist_ts_shared/index.js +10 -8
  15. package/dist_ts_shared/interfaces/document.d.ts +15 -2
  16. package/dist_ts_shared/interfaces/document.js +1 -1
  17. package/dist_ts_shared/translation.d.ts +79 -28
  18. package/dist_ts_shared/translation.js +121 -107
  19. package/dist_ts_web/ts_shared/translation.d.ts +82 -0
  20. package/dist_ts_web/ts_shared/translation.js +134 -0
  21. package/dist_ts_web/{00_commitinfo_data.js → ts_web/00_commitinfo_data.js} +2 -2
  22. package/dist_ts_web/{elements → ts_web/elements}/contentinvoice.d.ts +12 -6
  23. package/dist_ts_web/ts_web/elements/contentinvoice.js +466 -0
  24. package/dist_ts_web/{elements → ts_web/elements}/document.d.ts +10 -10
  25. package/dist_ts_web/ts_web/elements/document.demo.js +9 -0
  26. package/dist_ts_web/ts_web/elements/document.js +306 -0
  27. package/dist_ts_web/ts_web/elements/index.d.ts +10 -0
  28. package/dist_ts_web/ts_web/elements/index.js +11 -0
  29. package/dist_ts_web/ts_web/elements/letterheader.d.ts +18 -0
  30. package/dist_ts_web/ts_web/elements/letterheader.js +224 -0
  31. package/dist_ts_web/ts_web/elements/page.d.ts +25 -0
  32. package/dist_ts_web/ts_web/elements/page.js +335 -0
  33. package/dist_ts_web/{elements → ts_web/elements}/pagecontainer.d.ts +4 -4
  34. package/dist_ts_web/ts_web/elements/pagecontainer.js +114 -0
  35. package/dist_ts_web/{elements → ts_web/elements}/pagecontent.d.ts +7 -6
  36. package/dist_ts_web/ts_web/elements/pagecontent.js +177 -0
  37. package/dist_ts_web/ts_web/elements/pagefooter.d.ts +17 -0
  38. package/dist_ts_web/ts_web/elements/pagefooter.js +234 -0
  39. package/dist_ts_web/ts_web/elements/pageheader.d.ts +17 -0
  40. package/dist_ts_web/ts_web/elements/pageheader.js +165 -0
  41. package/dist_ts_web/ts_web/elements/paymentcode.d.ts +19 -0
  42. package/dist_ts_web/ts_web/elements/paymentcode.js +162 -0
  43. package/dist_ts_web/{elements → ts_web/elements}/viewer.d.ts +5 -5
  44. package/dist_ts_web/ts_web/elements/viewer.demo.js +9 -0
  45. package/dist_ts_web/ts_web/elements/viewer.js +150 -0
  46. package/dist_ts_web/{index.js → ts_web/index.js} +1 -1
  47. package/dist_ts_web/{pages → ts_web/pages}/index.js +1 -1
  48. package/dist_ts_web/ts_web/pages/page1.js +21 -0
  49. package/dist_ts_web/{pages → ts_web/pages}/page2.js +1 -1
  50. package/dist_ts_web/ts_web/plugins.js +14 -0
  51. package/dist_ts_web/ts_web/style.js +38 -0
  52. package/license +2 -2
  53. package/package.json +21 -19
  54. package/readme.hints.md +40 -1
  55. package/readme.md +202 -125
  56. package/ts/00_commitinfo_data.ts +1 -1
  57. package/ts/classes.pdfservice.ts +15 -7
  58. package/ts/helpers.ts +1 -1
  59. package/ts/paths.ts +3 -1
  60. package/ts/plugins.ts +3 -0
  61. package/ts_web/00_commitinfo_data.ts +1 -1
  62. package/ts_web/elements/contentinvoice.ts +272 -250
  63. package/ts_web/elements/document.demo.ts +7 -4
  64. package/ts_web/elements/document.ts +68 -82
  65. package/ts_web/elements/index.ts +10 -9
  66. package/ts_web/elements/letterheader.ts +106 -39
  67. package/ts_web/elements/page.ts +106 -48
  68. package/ts_web/elements/pagecontainer.ts +14 -13
  69. package/ts_web/elements/pagecontent.ts +34 -53
  70. package/ts_web/elements/pagefooter.ts +125 -45
  71. package/ts_web/elements/pageheader.ts +22 -16
  72. package/ts_web/elements/paymentcode.ts +95 -0
  73. package/ts_web/elements/viewer.demo.ts +7 -4
  74. package/ts_web/elements/viewer.ts +26 -12
  75. package/ts_web/pages/page1.ts +10 -6
  76. package/ts_web/style.ts +34 -3
  77. package/dist_ts_shared/interfaces/translation.d.ts +0 -19
  78. package/dist_ts_shared/interfaces/translation.js +0 -2
  79. package/dist_ts_web/elements/contentinvoice.js +0 -388
  80. package/dist_ts_web/elements/document.demo.js +0 -6
  81. package/dist_ts_web/elements/document.js +0 -272
  82. package/dist_ts_web/elements/index.d.ts +0 -9
  83. package/dist_ts_web/elements/index.js +0 -10
  84. package/dist_ts_web/elements/letterheader.d.ts +0 -16
  85. package/dist_ts_web/elements/letterheader.js +0 -124
  86. package/dist_ts_web/elements/page.d.ts +0 -25
  87. package/dist_ts_web/elements/page.js +0 -219
  88. package/dist_ts_web/elements/pagecontainer.js +0 -67
  89. package/dist_ts_web/elements/pagecontent.js +0 -143
  90. package/dist_ts_web/elements/pagefooter.d.ts +0 -17
  91. package/dist_ts_web/elements/pagefooter.js +0 -138
  92. package/dist_ts_web/elements/pageheader.d.ts +0 -17
  93. package/dist_ts_web/elements/pageheader.js +0 -109
  94. package/dist_ts_web/elements/viewer.demo.js +0 -6
  95. package/dist_ts_web/elements/viewer.js +0 -101
  96. package/dist_ts_web/pages/page1.js +0 -17
  97. package/dist_ts_web/plugins.js +0 -14
  98. package/dist_ts_web/style.js +0 -7
  99. package/dist_watch/bundle.js +0 -40318
  100. package/dist_watch/bundle.js.map +0 -7
  101. package/dist_watch/index.html +0 -25
  102. /package/dist_ts_web/{00_commitinfo_data.d.ts → ts_web/00_commitinfo_data.d.ts} +0 -0
  103. /package/dist_ts_web/{elements → ts_web/elements}/document.demo.d.ts +0 -0
  104. /package/dist_ts_web/{elements → ts_web/elements}/viewer.demo.d.ts +0 -0
  105. /package/dist_ts_web/{index.d.ts → ts_web/index.d.ts} +0 -0
  106. /package/dist_ts_web/{pages → ts_web/pages}/index.d.ts +0 -0
  107. /package/dist_ts_web/{pages → ts_web/pages}/page1.d.ts +0 -0
  108. /package/dist_ts_web/{pages → ts_web/pages}/page2.d.ts +0 -0
  109. /package/dist_ts_web/{plugins.d.ts → ts_web/plugins.d.ts} +0 -0
  110. /package/dist_ts_web/{style.d.ts → ts_web/style.d.ts} +0 -0
package/readme.md CHANGED
@@ -1,199 +1,276 @@
1
1
  # @design.estate/dees-document
2
2
 
3
- A comprehensive tool for dynamically generating and rendering business documents like invoices using modern web technologies.
3
+ A powerful TypeScript framework for dynamically generating professional business documents like invoices with web components and PDF export capabilities. 🧾
4
4
 
5
- ## Install
5
+ ## Issue Reporting and Security
6
6
 
7
- To incorporate `@design.estate/dees-document` into your project, execute the following command in your terminal:
7
+ For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
8
+
9
+ ## Installation
8
10
 
9
11
  ```shell
10
- npm install @design.estate/dees-document --save
12
+ pnpm install @design.estate/dees-document
11
13
  ```
12
14
 
13
- This command will install the package and add it to your project's dependencies, thus making all the necessary modules available within your `node_modules` directory.
14
-
15
- ## Usage
16
-
17
- The `@design.estate/dees-document` package serves as a robust framework to facilitate the generation of business documents, such as invoices, contracts, and reports. Leveraging modern web technologies, this package integrates seamlessly with TypeScript and ES modules, offering a type-safe environment conducive to efficient, dynamic document creation.
18
-
19
- Below, we provide a detailed guide for utilizing this package, from initializing your environment to generating complete PDF documents.
20
-
21
- ### Setting Up the Environment
22
-
23
- Before diving into document creation, ensure your environment is properly configured. Make sure to import necessary dependencies and setup configurations:
24
-
25
- ```typescript
26
- import { PdfService, IPdfServiceConstructorOptions } from '@design.estate/dees-document';
27
-
28
- async function setupPdfService() {
29
- const options: IPdfServiceConstructorOptions = {
30
- // Configure your options here
31
- };
32
-
33
- const pdfService = await PdfService.createAndStart(options);
34
- console.log('PDF Service started successfully.');
35
- return pdfService;
36
- }
37
- ```
15
+ ## Features
38
16
 
39
- In this setup snippet, you set up the `PdfService` which is the core component for PDF generation. The configuration options should be adjusted to fit your needs, especially considering options such as file paths, languages, and template directories.
17
+ - 📄 **PDF Generation** - Server-side PDF creation from structured data using Puppeteer
18
+ - 🎨 **Web Components** - Lit-based custom elements for document rendering
19
+ - 🌍 **Multi-language Support** - Built-in translation system (EN, DE, ES)
20
+ - 📱 **Automatic Pagination** - Smart content overflow handling across pages
21
+ - 💳 **QR Payment Codes** - EPC QR codes for SEPA payments
22
+ - 🖨️ **Print Mode** - Optimized rendering for both screen and print
23
+ - 📐 **A4 Format** - Precise DIN A4 document dimensions
24
+ - ✨ **Theming** - Customizable colors, backgrounds, and branding
40
25
 
41
- ### Creating a Document Template
26
+ ## Usage
42
27
 
43
- To create documents, particularly invoices, you'll first need to define a template. This template describes the structure of your document:
28
+ ### Server-Side PDF Generation
44
29
 
45
30
  ```typescript
46
- import { ILetter } from '@design.estate/dees-document';
47
-
48
- const invoiceTemplate: ILetter = {
31
+ import { PdfService } from '@design.estate/dees-document';
32
+ import type { TInvoice } from '@tsclass/tsclass/finance';
33
+
34
+ // Initialize the PDF service
35
+ const pdfService = new PdfService({});
36
+ await pdfService.start();
37
+
38
+ // Create invoice data
39
+ const invoice: TInvoice = {
40
+ type: 'invoice',
41
+ invoiceType: 'debitnote',
42
+ id: 'INV-2024-001',
43
+ invoiceId: 'INV-2024-001',
44
+ date: Date.now(),
45
+ currency: 'EUR',
46
+ dueInDays: 30,
47
+ reverseCharge: false,
49
48
  from: {
50
- name: 'Your Company Name',
49
+ name: 'Your Company GmbH',
50
+ type: 'company',
51
+ status: 'active',
51
52
  address: {
52
- streetName: 'Your Street',
53
+ streetName: 'Business Street',
53
54
  houseNumber: '123',
54
- city: 'Your City',
55
- country: 'Your Country',
56
- postalCode: '12345',
55
+ city: 'Berlin',
56
+ country: 'Germany',
57
+ postalCode: '10115',
58
+ },
59
+ sepaConnection: {
60
+ bic: 'DEUTDEFF',
61
+ iban: 'DE89370400440532013000',
62
+ },
63
+ registrationDetails: {
64
+ vatId: 'DE123456789',
65
+ registrationName: 'Amtsgericht Berlin',
66
+ registrationId: 'HRB 12345',
57
67
  },
58
- email: 'your-email@example.com',
59
- phone: '123-456-7890',
60
68
  },
61
69
  to: {
62
- name: 'Recipient Company Name',
70
+ name: 'Customer Inc.',
71
+ type: 'company',
72
+ status: 'active',
63
73
  address: {
64
- streetName: 'Recipient Street',
74
+ streetName: 'Client Avenue',
65
75
  houseNumber: '456',
66
- city: 'Recipient City',
67
- country: 'Recipient Country',
68
- postalCode: '67890',
76
+ city: 'Munich',
77
+ country: 'Germany',
78
+ postalCode: '80331',
69
79
  },
70
- email: 'recipient-email@example.com',
71
- phone: '098-765-4321',
72
- },
73
- content: {
74
- invoiceData: {
75
- items: [
76
- {
77
- name: 'Service or Product Name',
78
- unitQuantity: 2,
79
- unitNetPrice: 100.0,
80
- unitType: 'service',
81
- vatPercentage: 19,
82
- currency: 'EUR',
83
- },
84
- ],
80
+ registrationDetails: {
81
+ vatId: 'DE987654321',
85
82
  },
86
83
  },
87
- subject: 'Invoice for Services Rendered',
88
- date: new Date().getTime(),
84
+ items: [
85
+ {
86
+ name: 'Web Development Services',
87
+ unitQuantity: 40,
88
+ unitNetPrice: 95,
89
+ unitType: 'hours',
90
+ vatPercentage: 19,
91
+ position: 1,
92
+ },
93
+ {
94
+ name: 'Hosting (Annual)',
95
+ unitQuantity: 1,
96
+ unitNetPrice: 299,
97
+ unitType: 'item',
98
+ vatPercentage: 19,
99
+ position: 2,
100
+ },
101
+ ],
102
+ subject: 'Invoice INV-2024-001',
89
103
  versionInfo: {
90
104
  type: 'final',
91
105
  version: '1.0.0',
92
106
  },
93
107
  };
94
- ```
95
-
96
- The `invoiceTemplate` object utilizes the `ILetter` interface which specifies the structure for invoice data, including sender and recipient details, itemization, and pricing.
97
108
 
98
- ### Generating the Document
99
-
100
- Once a template is established, the next step is generating a PDF:
109
+ // Generate PDF
110
+ const pdfResult = await pdfService.createPdfFromLetterObject({
111
+ letterData: invoice,
112
+ documentSettings: {
113
+ languageCode: 'EN',
114
+ enableDefaultHeader: true,
115
+ enableDefaultFooter: true,
116
+ enableFoldMarks: true,
117
+ dateStyle: 'long',
118
+ },
119
+ });
101
120
 
102
- ```typescript
103
- async function generateInvoice(pdfService: PdfService, invoiceData: ILetter) {
104
- const pdfBuffer = await pdfService.createPdfFromLetterObject(invoiceData);
105
- console.log('Invoice PDF generated successfully.');
121
+ // Save to file
122
+ import { SmartFs, SmartFsProviderNode } from '@push.rocks/smartfs';
123
+ const fs = new SmartFs(new SmartFsProviderNode());
124
+ await fs.file('./invoice.pdf').write(Buffer.from(pdfResult.buffer));
106
125
 
107
- // Here you could save the PDF to your filesystem, send it via email, etc.
108
- }
126
+ // Don't forget to stop the service when done
127
+ await pdfService.stop();
109
128
  ```
110
129
 
111
- In this function, the `createPdfFromLetterObject` method converts your invoice data into a `Buffer` containing the PDF. This `Buffer` can subsequently be saved as a file or sent over HTTP.
130
+ ### Document Settings
112
131
 
113
- ### Comprehensive Example
114
-
115
- Below is an example integrating all previous steps into a single coherent script:
132
+ Customize document appearance with `IDocumentSettings`:
116
133
 
117
134
  ```typescript
118
- async function main() {
119
- const pdfService = await setupPdfService();
120
- const invoiceData: ILetter = {
121
- // Populate your invoice object
122
- };
123
- await generateInvoice(pdfService, invoiceData);
124
- }
125
-
126
- main().then(() => console.log('Invoice generation process completed.'));
135
+ const documentSettings = {
136
+ // Language for translations
137
+ languageCode: 'DE', // 'EN' | 'DE' | 'ES'
138
+
139
+ // Layout options
140
+ enableDefaultHeader: true,
141
+ enableDefaultFooter: true,
142
+ enableFoldMarks: true,
143
+ enableTopDraftText: true,
144
+ enableInvoiceContractRefSection: true,
145
+
146
+ // Display options
147
+ vatGroupPositions: true,
148
+ dateStyle: 'long', // 'short' | 'medium' | 'long' | 'full'
149
+
150
+ // Theming
151
+ theme: {
152
+ colorPrimaryForeground: '#ffffff',
153
+ colorPrimaryBackground: '#e4002b',
154
+ colorAccentForeground: '#333333',
155
+ colorAccentBackground: '#f5f5f5',
156
+ pageBackground: 'url(your-watermark.png)',
157
+ coverPageBackground: 'url(your-cover.png)',
158
+ },
159
+ };
127
160
  ```
128
161
 
129
- This script encompasses initializing services and generating a PDF in a streamlined, efficient workflow.
162
+ ### Web Component Usage
130
163
 
131
- ### Advanced Features
164
+ For browser-based document viewing:
132
165
 
133
- `@design.estate/dees-document` provides several advanced functionalities, enabling rich document creation:
166
+ ```typescript
167
+ import '@design.estate/dees-document/web';
168
+
169
+ // In your HTML/Lit template
170
+ html`
171
+ <dedocument-viewer
172
+ .letterData=${invoiceData}
173
+ .documentSettings=${documentSettings}
174
+ ></dedocument-viewer>
175
+ `;
176
+
177
+ // Or render the document directly
178
+ html`
179
+ <dedocument-dedocument
180
+ .letterData=${invoiceData}
181
+ .documentSettings=${documentSettings}
182
+ ></dedocument-dedocument>
183
+ `;
184
+ ```
134
185
 
135
- 1. **Custom Templates & Styling**
186
+ ### Translation System
136
187
 
137
- - Customize the styling through CSS or using inline styles in TypeScript.
138
- - Templates can be adjusted to present different document types (e.g., contracts, reports).
188
+ The package includes a translation system for multi-language document generation:
139
189
 
140
- 2. **Modular Components and Reuse**
190
+ ```typescript
191
+ import { translate } from '@design.estate/dees-document/shared';
141
192
 
142
- - Utilize modular components to create reusable parts across different documents, enhancing maintainability and reducing redundancy.
193
+ // Translate document labels
194
+ translate('DE', 'invoice@@totalGross'); // "Gesamtbetrag (Brutto)"
195
+ translate('EN', 'invoice@@totalGross'); // "Total (Gross)"
196
+ translate('ES', 'invoice@@totalGross'); // "Total (Bruto)"
197
+ ```
143
198
 
144
- 3. **Interactive Documents**
199
+ ## Module Exports
145
200
 
146
- - Integrate interactivities like forms, buttons, and interactive charts within your documents.
201
+ The package provides multiple entry points:
147
202
 
148
- 4. **Localization Support**
203
+ ```typescript
204
+ // Node.js server-side (PDF generation)
205
+ import { PdfService } from '@design.estate/dees-document';
206
+ import { PdfService } from '@design.estate/dees-document/node';
149
207
 
150
- - Documents can be localized to support multiple languages, enhancing accessibility and usability.
208
+ // Browser web components
209
+ import '@design.estate/dees-document/web';
151
210
 
152
- 5. **Responsive and Adaptive Designs**
211
+ // Shared utilities and types
212
+ import { translate, IDocumentSettings } from '@design.estate/dees-document/shared';
153
213
 
154
- - Create documents that adjust layout dynamically depending on print or digital medium, maintaining consistency across platforms.
214
+ // TypeScript interfaces
215
+ import type { IDocumentSettings } from '@design.estate/dees-document/interfaces';
216
+ ```
155
217
 
156
- 6. **Security Features**
218
+ ## Document Components
157
219
 
158
- - Apply digital signatures and encrypt sensitive documents to ensure secure and authentic document distribution.
220
+ The framework includes these web components:
159
221
 
160
- 7. **Complex Business Logic**
161
- - Implement complex logic for feature-rich documents such as inventory systems, automatic tax calculations, or real-time pricing adjustments.
222
+ | Component | Description |
223
+ |-----------|-------------|
224
+ | `<dedocument-dedocument>` | Main document container with pagination |
225
+ | `<dedocument-viewer>` | Document viewer with controls |
226
+ | `<dedocument-page>` | Single A4 page with scaling support |
227
+ | `<dedocument-pageheader>` | Company logo and branding header |
228
+ | `<dedocument-letterheader>` | Sender/recipient addresses |
229
+ | `<dedocument-pagecontent>` | Main content area |
230
+ | `<dedocument-pagefooter>` | Company info and page numbers |
231
+ | `<dedocument-contentinvoice>` | Invoice-specific content layout |
232
+ | `<dedocument-paymentcode>` | EPC QR code for SEPA payments |
162
233
 
163
- ### Utilize Translation for Localization
234
+ ## Draft vs Final Documents
164
235
 
165
- The package offers a translation mechanism to adapt your documents for international clients:
236
+ Control document version display:
166
237
 
167
238
  ```typescript
168
- import { translate } from '@design.estate/dees-document/shared';
239
+ const invoice = {
240
+ // ... other fields
241
+ versionInfo: {
242
+ type: 'draft', // Shows watermark "DRAFT" across pages
243
+ version: '0.1.0',
244
+ },
245
+ };
169
246
 
170
- const languageCode: 'DE' | 'EN' | 'ES' = 'EN'; // Set required language code
171
- console.log(translate(languageCode, 'invoice', 'Invoice')); // Translated output
247
+ // For final documents
248
+ const invoice = {
249
+ // ... other fields
250
+ versionInfo: {
251
+ type: 'final', // Clean document without watermark
252
+ version: '1.0.0',
253
+ },
254
+ };
172
255
  ```
173
256
 
174
- Different language settings can be applied, enabling the seamless presentation of document contents tailored to regional and linguistic preferences.
175
-
176
- ### Conclusion
177
-
178
- The `@design.estate/dees-document` package is a versatile and powerful solution for businesses seeking to automate and streamline their document generation processes using modern web technologies. By integrating seamlessly with TypeScript, it offers robust capabilities for creating complex, customizable, and interactive documents that can meet a variety of business needs.
179
-
180
- From custom templates to localization and advanced security features, this module provides the flexibility and power to create polished and professional documents efficiently. Whether you're generating invoices, contracts, or detailed reports, `@design.estate/dees-document` has the tools to support your enterprise workflows with ease and precision.
181
-
182
257
  ## License and Legal Information
183
258
 
184
- This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
259
+ This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./LICENSE) file.
185
260
 
186
261
  **Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
187
262
 
188
263
  ### Trademarks
189
264
 
190
- This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
265
+ This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.
266
+
267
+ Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
191
268
 
192
269
  ### Company Information
193
270
 
194
- Task Venture Capital GmbH
195
- Registered at District court Bremen HRB 35230 HB, Germany
271
+ Task Venture Capital GmbH
272
+ Registered at District Court Bremen HRB 35230 HB, Germany
196
273
 
197
- For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
274
+ For any legal inquiries or further information, please contact us via email at hello@task.vc.
198
275
 
199
276
  By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@design.estate/dees-document',
6
- version: '1.6.9',
6
+ version: '2.0.2',
7
7
  description: 'A sophisticated framework for dynamically generating and rendering business documents like invoices with modern web technologies, featuring PDF creation, templating, and automation.'
8
8
  }
@@ -1,5 +1,5 @@
1
- import * as plugins from './plugins.js';
2
- import * as helpers from './helpers.js';
1
+ import * as plugins from "./plugins.js";
2
+ import * as helpers from "./helpers.js";
3
3
 
4
4
  export interface IPdfServiceConstructorOptions {}
5
5
 
@@ -8,7 +8,9 @@ export interface IPdfServiceConstructorOptions {}
8
8
  */
9
9
  export class PdfService {
10
10
  // STATIC
11
- public static async createAndStart(optionsArg: IPdfServiceConstructorOptions) {
11
+ public static async createAndStart(
12
+ optionsArg: IPdfServiceConstructorOptions
13
+ ) {
12
14
  const pdfService = new PdfService(optionsArg);
13
15
  await pdfService.start();
14
16
  return pdfService;
@@ -42,17 +44,23 @@ export class PdfService {
42
44
  * creates an letter
43
45
  */
44
46
  public async createPdfFromLetterObject(optionsArg: {
45
- letterData: plugins.tsclass.business.ILetter;
47
+ letterData: plugins.tsclass.business.TLetter;
46
48
  documentSettings: plugins.shared.interfaces.IDocumentSettings;
47
- }) {
49
+ }): Promise<plugins.smartpdf.IPdf> {
48
50
  const html = `
49
51
  <script type="module">
50
52
  ${await helpers.getBundleAsString()}
51
53
  </script>
52
- <dedocument-dedocument printMode documentSettings="${plugins.smartjson.stringifyBase64(optionsArg.documentSettings)}" letterData="${plugins.smartjson.stringifyBase64(optionsArg.letterData)}"></dedocument-dedocument>
54
+ <dedocument-dedocument printMode documentSettings="${plugins.smartjson.stringifyBase64(
55
+ optionsArg.documentSettings
56
+ )}" letterData="${plugins.smartjson.stringifyBase64(
57
+ optionsArg.letterData
58
+ )}"></dedocument-dedocument>
53
59
  `;
54
60
  // console.log(html);
55
- const pdfResult = await this.smartpdfInstance.getA4PdfResultForHtmlString(html);
61
+ const pdfResult = await this.smartpdfInstance.getA4PdfResultForHtmlString(
62
+ html
63
+ );
56
64
  return pdfResult;
57
65
  }
58
66
  }
package/ts/helpers.ts CHANGED
@@ -2,5 +2,5 @@ import * as plugins from './plugins.js';
2
2
  import * as paths from './paths.js';
3
3
 
4
4
  export const getBundleAsString = async () => {
5
- return plugins.smartfile.fs.toStringSync(paths.bundleFile);
5
+ return plugins.smartfs.file(paths.bundleFile).encoding('utf8').read();
6
6
  };
package/ts/paths.ts CHANGED
@@ -6,7 +6,9 @@ export const packageDir = plugins.path.join(
6
6
  );
7
7
 
8
8
  export const nogitDir = plugins.path.join(packageDir, '.nogit/');
9
- plugins.smartfile.fs.ensureDirSync(nogitDir);
9
+ if (!(await plugins.smartfs.directory(nogitDir).exists())) {
10
+ await plugins.smartfs.directory(nogitDir).create();
11
+ }
10
12
 
11
13
  export const bundleDir = plugins.path.join(packageDir, './dist_bundle');
12
14
  export const bundleFile = plugins.path.join(bundleDir, './bundle.js');
package/ts/plugins.ts CHANGED
@@ -10,10 +10,13 @@ export { shared };
10
10
 
11
11
  // @push.rocks/scope
12
12
  import * as smartfile from '@push.rocks/smartfile';
13
+ import { SmartFs, SmartFsProviderNode } from '@push.rocks/smartfs';
13
14
  import * as smartjson from '@push.rocks/smartjson';
14
15
  import * as smartpath from '@push.rocks/smartpath';
15
16
  import * as smartpdf from '@push.rocks/smartpdf';
16
17
 
18
+ export const smartfs = new SmartFs(new SmartFsProviderNode());
19
+
17
20
  export { smartfile, smartpath, smartjson, smartpdf };
18
21
 
19
22
  // @tsclass scope
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@design.estate/dees-document',
6
- version: '1.6.9',
6
+ version: '2.0.2',
7
7
  description: 'A sophisticated framework for dynamically generating and rendering business documents like invoices with modern web technologies, featuring PDF creation, templating, and automation.'
8
8
  }