feat(core): Enhance document generation capabilities with improved modular structure and extended translation support.
This commit is contained in:
parent
ab2c1e21f2
commit
4c9b2671a9
@ -1,5 +1,14 @@
|
||||
# Changelog
|
||||
|
||||
## 2024-12-01 - 1.2.0 - feat(core)
|
||||
Enhance document generation capabilities with improved modular structure and extended translation support.
|
||||
|
||||
- Enhanced document generation framework with a more modular structure.
|
||||
- Integrated support for translations using JSON-based language maps.
|
||||
- Optimized PDF generation process for dynamic document content.
|
||||
- Added properties in 'IDocumentSettings' for language code management.
|
||||
- Updated README documentation with more comprehensive examples and guidance.
|
||||
|
||||
## 2024-11-30 - 1.1.0 - feat(core)
|
||||
Enhanced document generation features and added translation capabilities
|
||||
|
||||
|
@ -5,29 +5,26 @@
|
||||
"githost": "code.foss.global",
|
||||
"gitscope": "designestate/private",
|
||||
"gitrepo": "dedocument-catalog",
|
||||
"description": "A versatile tool for dynamically generating and rendering business documents, such as invoices, using modern web technologies and elements.",
|
||||
"description": "A comprehensive tool for dynamically generating and rendering business documents like invoices using modern web technologies.",
|
||||
"npmPackagename": "@designestate_private/dedocument-catalog",
|
||||
"license": "MIT",
|
||||
"projectDomain": "design.estate",
|
||||
"shortDescription": "undefined variable",
|
||||
"keywords": [
|
||||
"document generation",
|
||||
"invoices",
|
||||
"PDF creation",
|
||||
"TypeScript",
|
||||
"web components",
|
||||
"templating",
|
||||
"dynamic rendering",
|
||||
"responsive design",
|
||||
"invoice automation",
|
||||
"business documentation",
|
||||
"automated workflows",
|
||||
"modular architecture",
|
||||
"smart contracts",
|
||||
"javascript",
|
||||
"dynamic rendering",
|
||||
"PDF creation",
|
||||
"web components",
|
||||
"Node.js",
|
||||
"TypeScript",
|
||||
"templating",
|
||||
"modern web technologies",
|
||||
"responsive design",
|
||||
"QR code",
|
||||
"custom elements",
|
||||
"nodejs",
|
||||
"data-driven"
|
||||
"modular architecture",
|
||||
"automated workflows"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
28
package.json
28
package.json
@ -2,7 +2,7 @@
|
||||
"name": "@design.estate/dees-document",
|
||||
"version": "1.1.0",
|
||||
"private": false,
|
||||
"description": "A versatile tool for dynamically generating and rendering business documents, such as invoices, using modern web technologies and elements.",
|
||||
"description": "A comprehensive tool for dynamically generating and rendering business documents like invoices using modern web technologies.",
|
||||
"main": "dist_ts_web/index.js",
|
||||
"typings": "dist_ts_web/index.d.ts",
|
||||
"exports": {
|
||||
@ -28,6 +28,7 @@
|
||||
"@push.rocks/smartpdf": "^3.1.8",
|
||||
"@push.rocks/smarttime": "^4.0.8",
|
||||
"@tsclass/tsclass": "^4.1.2",
|
||||
"@types/node": "^22.10.1",
|
||||
"@types/qrcode": "^1.5.5",
|
||||
"qrcode": "^1.5.4"
|
||||
},
|
||||
@ -65,21 +66,18 @@
|
||||
"homepage": "https://gitlab.com/designestate/private/dedocument-catalog#readme",
|
||||
"keywords": [
|
||||
"document generation",
|
||||
"invoices",
|
||||
"PDF creation",
|
||||
"TypeScript",
|
||||
"web components",
|
||||
"templating",
|
||||
"dynamic rendering",
|
||||
"responsive design",
|
||||
"invoice automation",
|
||||
"business documentation",
|
||||
"automated workflows",
|
||||
"modular architecture",
|
||||
"smart contracts",
|
||||
"javascript",
|
||||
"dynamic rendering",
|
||||
"PDF creation",
|
||||
"web components",
|
||||
"Node.js",
|
||||
"TypeScript",
|
||||
"templating",
|
||||
"modern web technologies",
|
||||
"responsive design",
|
||||
"QR code",
|
||||
"custom elements",
|
||||
"nodejs",
|
||||
"data-driven"
|
||||
"modular architecture",
|
||||
"automated workflows"
|
||||
]
|
||||
}
|
3
pnpm-lock.yaml
generated
3
pnpm-lock.yaml
generated
@ -38,6 +38,9 @@ importers:
|
||||
'@tsclass/tsclass':
|
||||
specifier: ^4.1.2
|
||||
version: 4.1.2
|
||||
'@types/node':
|
||||
specifier: ^22.10.1
|
||||
version: 22.10.1
|
||||
'@types/qrcode':
|
||||
specifier: ^1.5.5
|
||||
version: 1.5.5
|
||||
|
57
readme.md
57
readme.md
@ -1,31 +1,32 @@
|
||||
```markdown
|
||||
# @design.estate/dees-document
|
||||
|
||||
A comprehensive solution for generating documents like invoices, integrating elements, templates, and services to streamline document creation.
|
||||
A versatile tool for dynamically generating and rendering business documents, such as invoices, using modern web technologies and elements.
|
||||
|
||||
## Install
|
||||
|
||||
To add `@design.estate/dees-document` to your project, run the following command in your terminal:
|
||||
To incorporate `@design.estate/dees-document` into your project, execute the following command in your terminal:
|
||||
|
||||
```shell
|
||||
npm install @design.estate/dees-document --save
|
||||
```
|
||||
|
||||
This will install the package and add it to your project's dependencies, ensuring all required modules are available in your `node_modules` directory.
|
||||
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.
|
||||
|
||||
## Usage
|
||||
|
||||
The `@design.estate/dees-document` package provides a robust framework for creating documents including invoices, contracts, and various other business-related documents. It is built on modern web technologies including TypeScript and ES modules to ensure a type-safe and easy-to-integrate experience. Below, we will guide you through the comprehensive usage of this package, from setting up your environment to generating PDF documents.
|
||||
The `@design.estate/dees-document` package serves as a robust framework to facilitate the generation of business documents, such as invoices and contracts. Leveraging modern web technologies, this package integrates seamlessly with TypeScript and ES modules, offering a type-safe environment conducive to efficient, dynamic document creation. Presented here is a comprehensive guide to utilizing this package, ranging from initializing your environment to generating complete PDF documents.
|
||||
|
||||
### Getting Started
|
||||
|
||||
Before creating documents, initialize the document service which is central to this package. This is typically done at the beginning of your application.
|
||||
To embark on a document creation journey, initiate the document service. This service constitutes the core of this package and is typically started at the application's outset.
|
||||
|
||||
```typescript
|
||||
import { PdfService, IPdfServiceConstructorOptions } from '@design.estate/dees-document';
|
||||
|
||||
async function setupPdfService() {
|
||||
const options: IPdfServiceConstructorOptions = {
|
||||
// Add necessary configuration here
|
||||
// configure your options here
|
||||
};
|
||||
|
||||
const pdfService = await PdfService.createAndStart(options);
|
||||
@ -34,15 +35,15 @@ async function setupPdfService() {
|
||||
}
|
||||
```
|
||||
|
||||
This script initializes `PdfService`. Modify the options to tailor the service to your needs.
|
||||
The above code initializes the `PdfService`. Tailor the configuration options to suit your specific requirements.
|
||||
|
||||
### Creating Documents
|
||||
|
||||
With the PDF service ready, you can proceed to generate documents. The following section provides a detailed example of creating an invoice. This example is applicable to various document types with necessary adjustments.
|
||||
With the PDF service initialized, you can now proceed to generate your documents. In the following section, you will find a detailed walkthrough for creating an invoice. This method can be adapted to other document types with necessary modifications.
|
||||
|
||||
#### Step-by-Step: Create an Invoice
|
||||
|
||||
1. **Define the Data Structure**: Describe the invoice details. This includes sender and recipient information, the items being invoiced, and more.
|
||||
1. **Define the Data Structure**: Construct the details of the invoice, including the sender, recipient information, and the details of the items being invoiced.
|
||||
|
||||
```typescript
|
||||
import { ILetter } from '@design.estate/dees-document';
|
||||
@ -95,22 +96,22 @@ With the PDF service ready, you can proceed to generate documents. The following
|
||||
};
|
||||
```
|
||||
|
||||
Here, `ILetter` interface details all components of an invoice including sender (`from`) and recipient (`to`) information, as well as the invoiced items.
|
||||
The `ILetter` interface captures all the components of an invoice, including both the sender (`from`) and recipient (`to`) information, alongside the details of the invoiced items.
|
||||
|
||||
2. **Generate the PDF**: Transform the invoice details into a PDF.
|
||||
2. **Generate the PDF**: Convert the invoice details into a PDF file.
|
||||
|
||||
```typescript
|
||||
async function generateInvoice(pdfService: PdfService, invoiceData: ILetter) {
|
||||
const pdfBuffer = await pdfService.createPdfFromLetterObject(invoiceData);
|
||||
console.log('Invoice PDF generated successfully.');
|
||||
|
||||
// Save the PDF, send it via email, etc.
|
||||
// Here you could save the PDF to your filesystem, send it via email, etc.
|
||||
}
|
||||
```
|
||||
|
||||
The function `createPdfFromLetterObject` returns a `Buffer` containing the generated PDF. From here, you can save this PDF to a file, send it to clients, or archive it.
|
||||
The `createPdfFromLetterObject` function returns a `Buffer` that contains the generated PDF, enabling you to save it to a file, send it to clients, or store it for record-keeping.
|
||||
|
||||
3. **Integrate It All**: Here's how everything ties together into a complete script for generating an invoice:
|
||||
3. **Integrate It All**: The following script ties together the PDF service and generates the invoice with the described data.
|
||||
|
||||
```typescript
|
||||
async function main() {
|
||||
@ -121,15 +122,15 @@ With the PDF service ready, you can proceed to generate documents. The following
|
||||
main().then(() => console.log('Invoice generation process completed.'));
|
||||
```
|
||||
|
||||
This script initiates the PDF service and generates the invoice PDF with the provided information.
|
||||
This example initiates the PDF service and utilizes it to generate a PDF invoice with specified parameters.
|
||||
|
||||
### Advanced Document Features
|
||||
|
||||
The package is designed to create not only invoices but a wide range of document types. Leverage its modular architecture to build and customize documents to fit specific needs.
|
||||
The package is designed to create a broad range of documents, far beyond simple invoices. Utilize the modular architecture to customize documents to your specific business requirements.
|
||||
|
||||
#### Advanced Scenarios
|
||||
|
||||
1. **Custom Styling**: Customize the appearance of elements within your documents, such as headers, footers, and more.
|
||||
1. **Custom Styling**: Alter the visual styles of various elements within your documents, like headers, footers, and more through CSS or inline styles.
|
||||
|
||||
```typescript
|
||||
import { DeDocumentViewer } from '@design.estate/dees-element';
|
||||
@ -139,31 +140,33 @@ The package is designed to create not only invoices but a wide range of document
|
||||
document.body.appendChild(customStyledViewer);
|
||||
```
|
||||
|
||||
Customize via CSS or dynamically through TypeScript where necessary.
|
||||
Adjust styles either with standard CSS or via dynamic TypeScript changes.
|
||||
|
||||
2. **Interactive Document Elements**: Incorporate UI components like buttons, input fields, or visualizations tailored for your document needs.
|
||||
2. **Interactive Document Elements**: Integrate interactive UI components, like buttons or input fields, fitting seamlessly into your documents.
|
||||
|
||||
3. **Multi-page Document Generation**: Handle overflow of content and automatic page generation while maintaining headers and footers.
|
||||
3. **Multi-page Document Generation**: Handle content overflow elegantly through automatic page creation, keeping headers and footers intact.
|
||||
|
||||
```typescript
|
||||
pdfService.adjustDePageScaling();
|
||||
```
|
||||
|
||||
Toggle between print and digital formats and handle scaling.
|
||||
Adapt between print and digital formats, managing scaling effectively.
|
||||
|
||||
4. **Embedding Images and Logos**: Add company logos, graphics, or auxiliary content to enhance document presentation.
|
||||
4. **Embedding Images and Logos**: Enhance your document's appearance with company logos, graphics, and other auxiliary content.
|
||||
|
||||
### Additional Capabilities
|
||||
|
||||
Beyond these examples, delve deeper into advanced functionalities such as:
|
||||
Beyond basic functionality, this package offers a range of advanced features:
|
||||
|
||||
- **Document Management**: Manage multiple document templates, manage versions, and add annotations or notes.
|
||||
- **Dynamic Rendering**: Use templating for dynamic content rendering based on variable inputs.
|
||||
- **Responsive Design for Digital Documents**: Ensure documents are displayed correctly across devices.
|
||||
- **Document Management**: Manage multiple document templates, maintain version control, and append annotations or notes.
|
||||
- **Dynamic Rendering**: Utilize templating engines to render dynamic content based on input variables.
|
||||
- **Responsive Design for Digital Documents**: Ensure your documents are consistently displayed across various devices.
|
||||
|
||||
### Concluding Remarks
|
||||
|
||||
The `@design.estate/dees-document` package is an essential tool in the modern document generation ecosystem. Its expansive capabilities, from basic invoices to complex document templates, make it a versatile solution for businesses of all scales. Implementing this service broadly simplifies document management workflows and enhances document presentation precision and quality. For further depth, consult the package's documentation or explore the examples included in the module.
|
||||
The `@design.estate/dees-document` package presents a powerful solution within the modern document generation realm. From basic invoices to intricate templates, this package provides the essential tools for businesses to streamline their document workflows and enhance their presentation quality and accuracy. Explore further depth by consulting the package’s detailed documentation or by reviewing the examples included within the module.
|
||||
```
|
||||
|
||||
|
||||
## License and Legal Information
|
||||
|
||||
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@design.estate/dees-document',
|
||||
version: '1.1.0',
|
||||
description: 'A versatile tool for dynamically generating and rendering business documents, such as invoices, using modern web technologies and elements.'
|
||||
version: '1.2.0',
|
||||
description: 'A comprehensive tool for dynamically generating and rendering business documents like invoices using modern web technologies.'
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
import * as shared from '../shared/index.js';
|
||||
|
||||
export interface IDocumentSettings {
|
||||
enableTopDraftText?: boolean;
|
||||
enableDefaultHeader?: boolean;
|
||||
enableDefaultFooter?: boolean;
|
||||
languageCode?: shared.translation.TLanguageCode;
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
import * as tsclass from '@tsclass/tsclass';
|
||||
import * as interfaces from '../interfaces/index.js';
|
||||
|
||||
const fromContact: tsclass.business.IContact = {
|
||||
name: 'Awesome From Company',
|
||||
type: 'company',
|
||||
@ -208,3 +210,10 @@ export const demoLetter: tsclass.business.ILetter = {
|
||||
pdfAttachments: null,
|
||||
subject: 'Invoice: LL-INV-48765',
|
||||
}
|
||||
|
||||
export const demoDocumentSettings: interfaces.IDocumentSettings = {
|
||||
enableTopDraftText: true,
|
||||
enableDefaultHeader: true,
|
||||
enableDefaultFooter: true,
|
||||
languageCode: 'DE',
|
||||
};
|
@ -1,4 +1,4 @@
|
||||
import * as interfaces from '../../../ts/interfaces/index.js';
|
||||
import * as interfaces from '../interfaces/index.js';
|
||||
|
||||
type TTranslationImplementation = {
|
||||
[key in keyof interfaces.IDeDocumentTranslations]: string;
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@design.estate/dees-document',
|
||||
version: '1.1.0',
|
||||
description: 'A versatile tool for dynamically generating and rendering business documents, such as invoices, using modern web technologies and elements.'
|
||||
version: '1.2.0',
|
||||
description: 'A comprehensive tool for dynamically generating and rendering business documents like invoices using modern web technologies.'
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ import {
|
||||
domtools,
|
||||
} from '@design.estate/dees-element';
|
||||
import * as plugins from '../plugins.js';
|
||||
import * as shared from './shared/index.js';
|
||||
import * as shared from '../../ts/shared/index.js';
|
||||
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as shared from './shared/index.js';
|
||||
import * as shared from '../../ts/shared/index.js';
|
||||
import { html } from '@design.estate/dees-element';
|
||||
|
||||
export const demoFunc = () => html`
|
||||
|
@ -24,7 +24,7 @@ export const defaultDocumentSettings: interfaces.IDocumentSettings = {
|
||||
import { DePage } from './page.js';
|
||||
import { DeContentInvoice } from './contentinvoice.js';
|
||||
|
||||
import * as shared from './shared/index.js';
|
||||
import * as shared from '../../ts/shared/index.js';
|
||||
import { demoFunc } from './document.demo.js';
|
||||
|
||||
declare global {
|
||||
|
@ -8,4 +8,4 @@ export * from './pagefooter.js';
|
||||
export * from './pageheader.js';
|
||||
export * from './viewer.js';
|
||||
|
||||
export * from './shared/index.js';
|
||||
export * from '../../ts/shared/index.js';
|
@ -10,7 +10,7 @@ import {
|
||||
} from '@design.estate/dees-element';
|
||||
import * as domtools from '@design.estate/dees-domtools';
|
||||
|
||||
import * as shared from './shared/index.js';
|
||||
import * as shared from '../../ts/shared/index.js';
|
||||
import * as tsclass from '@tsclass/tsclass';
|
||||
|
||||
declare global {
|
||||
|
@ -15,7 +15,7 @@ import * as interfaces from '../../ts/interfaces/index.js';
|
||||
|
||||
import { defaultDocumentSettings } from './document.js';
|
||||
|
||||
import * as shared from './shared/index.js';
|
||||
import * as shared from '../../ts/shared/index.js';
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
|
@ -10,7 +10,7 @@ import {
|
||||
} from '@design.estate/dees-element';
|
||||
import * as domtools from '@design.estate/dees-domtools';
|
||||
|
||||
import * as shared from './shared/index.js';
|
||||
import * as shared from '../../ts/shared/index.js';
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
|
@ -10,7 +10,7 @@ import {
|
||||
} from '@design.estate/dees-element';
|
||||
import * as domtools from '@design.estate/dees-domtools';
|
||||
|
||||
import * as shared from './shared/index.js';
|
||||
import * as shared from '../../ts/shared/index.js';
|
||||
import * as tsclass from '@tsclass/tsclass';
|
||||
|
||||
declare global {
|
||||
|
@ -10,7 +10,7 @@ import {
|
||||
} from '@design.estate/dees-element';
|
||||
import * as domtools from '@design.estate/dees-domtools';
|
||||
|
||||
import * as shared from './shared/index.js';
|
||||
import * as shared from '../../ts/shared/index.js';
|
||||
import * as tsclass from '@tsclass/tsclass';
|
||||
|
||||
declare global {
|
||||
|
@ -10,7 +10,7 @@ import {
|
||||
} from '@design.estate/dees-element';
|
||||
import * as domtools from '@design.estate/dees-domtools';
|
||||
|
||||
import * as shared from './shared/index.js';
|
||||
import * as shared from '../../ts/shared/index.js';
|
||||
import * as tsclass from '@tsclass/tsclass';
|
||||
|
||||
declare global {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { html } from '@design.estate/dees-element';
|
||||
import * as shared from './shared/index.js';
|
||||
import * as shared from '../../ts/shared/index.js';
|
||||
|
||||
export const demoFunc = () => html`
|
||||
<dedocument-viewer .letterData=${shared.demoLetter}></dedocument-viewer>
|
||||
<dedocument-viewer .letterData=${shared.demoLetter} .documentSettings=${shared.demoDocumentSettings}></dedocument-viewer>
|
||||
`;
|
@ -1,7 +1,9 @@
|
||||
import * as plugins from '../plugins.js';
|
||||
import * as interfaces from '../../ts/interfaces/index.js';
|
||||
|
||||
import { DeesElement, css, cssManager, customElement, html } from '@design.estate/dees-element';
|
||||
import { demoFunc } from './viewer.demo.js';
|
||||
import { defaultDocumentSettings } from './document.js';
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
@ -17,6 +19,8 @@ export class DeDocumentViewer extends DeesElement {
|
||||
// INSTANCE
|
||||
public letterData: plugins.tsclass.business.ILetter = null;
|
||||
|
||||
public documentSettings: interfaces.IDocumentSettings = defaultDocumentSettings;
|
||||
|
||||
public static styles = [
|
||||
cssManager.defaultStyles,
|
||||
css`
|
||||
@ -67,7 +71,7 @@ export class DeDocumentViewer extends DeesElement {
|
||||
<div class="maincontainer">
|
||||
<div class="viewport">
|
||||
${this.letterData
|
||||
? html` <dedocument-dedocument .letterData=${this.letterData}></dedocument-dedocument> `
|
||||
? html` <dedocument-dedocument .letterData=${this.letterData} .documentSettings=${this.documentSettings}></dedocument-dedocument> `
|
||||
: html``}
|
||||
</div>
|
||||
<div class="controls"></div>
|
||||
|
Loading…
Reference in New Issue
Block a user