@design.estate/dees-document

A comprehensive tool for dynamically generating and rendering business documents like invoices using modern web technologies.

readme.md for @design.estate/dees-document

A powerful TypeScript framework for dynamically generating professional business documents like invoices with web components and PDF export capabilities. ๐Ÿงพ

Issue Reporting and Security

For reporting bugs, issues, or security vulnerabilities, please visit 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/ account to submit Pull Requests directly.

Installation

pnpm install @design.estate/dees-document

Features

Usage

Server-Side PDF Generation

import { PdfService } from '@design.estate/dees-document';
import type { TInvoice } from '@tsclass/tsclass/finance';

// Initialize the PDF service
const pdfService = new PdfService({});
await pdfService.start();

// Create invoice data
const invoice: TInvoice = {
  type: 'invoice',
  invoiceType: 'debitnote',
  id: 'INV-2024-001',
  invoiceId: 'INV-2024-001',
  date: Date.now(),
  currency: 'EUR',
  dueInDays: 30,
  reverseCharge: false,
  from: {
    name: 'Your Company GmbH',
    type: 'company',
    status: 'active',
    address: {
      streetName: 'Business Street',
      houseNumber: '123',
      city: 'Berlin',
      country: 'Germany',
      postalCode: '10115',
    },
    sepaConnection: {
      bic: 'DEUTDEFF',
      iban: 'DE89370400440532013000',
    },
    registrationDetails: {
      vatId: 'DE123456789',
      registrationName: 'Amtsgericht Berlin',
      registrationId: 'HRB 12345',
    },
  },
  to: {
    name: 'Customer Inc.',
    type: 'company',
    status: 'active',
    address: {
      streetName: 'Client Avenue',
      houseNumber: '456',
      city: 'Munich',
      country: 'Germany',
      postalCode: '80331',
    },
    registrationDetails: {
      vatId: 'DE987654321',
    },
  },
  items: [
    {
      name: 'Web Development Services',
      unitQuantity: 40,
      unitNetPrice: 95,
      unitType: 'hours',
      vatPercentage: 19,
      position: 1,
    },
    {
      name: 'Hosting (Annual)',
      unitQuantity: 1,
      unitNetPrice: 299,
      unitType: 'item',
      vatPercentage: 19,
      position: 2,
    },
  ],
  subject: 'Invoice INV-2024-001',
  versionInfo: {
    type: 'final',
    version: '1.0.0',
  },
};

// Generate PDF
const pdfResult = await pdfService.createPdfFromLetterObject({
  letterData: invoice,
  documentSettings: {
    languageCode: 'EN',
    enableDefaultHeader: true,
    enableDefaultFooter: true,
    enableFoldMarks: true,
    dateStyle: 'long',
  },
});

// Save to file
import { SmartFs, SmartFsProviderNode } from '@push.rocks/smartfs';
const fs = new SmartFs(new SmartFsProviderNode());
await fs.file('./invoice.pdf').write(Buffer.from(pdfResult.buffer));

// Don't forget to stop the service when done
await pdfService.stop();

Document Settings

Customize document appearance with IDocumentSettings:

const documentSettings = {
  // Language for translations
  languageCode: 'DE', // 'EN' | 'DE' | 'ES'

  // Layout options
  enableDefaultHeader: true,
  enableDefaultFooter: true,
  enableFoldMarks: true,
  enableTopDraftText: true,
  enableInvoiceContractRefSection: true,

  // Display options
  vatGroupPositions: true,
  dateStyle: 'long', // 'short' | 'medium' | 'long' | 'full'

  // Theming
  theme: {
    colorPrimaryForeground: '#ffffff',
    colorPrimaryBackground: '#e4002b',
    colorAccentForeground: '#333333',
    colorAccentBackground: '#f5f5f5',
    pageBackground: 'url(your-watermark.png)',
    coverPageBackground: 'url(your-cover.png)',
  },
};

Web Component Usage

For browser-based document viewing:

import '@design.estate/dees-document/web';

// In your HTML/Lit template
html`
  <dedocument-viewer
    .letterData=${invoiceData}
    .documentSettings=${documentSettings}
  ></dedocument-viewer>
`;

// Or render the document directly
html`
  <dedocument-dedocument
    .letterData=${invoiceData}
    .documentSettings=${documentSettings}
  ></dedocument-dedocument>
`;

Translation System

The package includes a translation system for multi-language document generation:

import { translate } from '@design.estate/dees-document/shared';

// Translate document labels
translate('DE', 'invoice@@totalGross'); // "Gesamtbetrag (Brutto)"
translate('EN', 'invoice@@totalGross'); // "Total (Gross)"
translate('ES', 'invoice@@totalGross'); // "Total (Bruto)"

Module Exports

The package provides multiple entry points:

// Node.js server-side (PDF generation)
import { PdfService } from '@design.estate/dees-document';
import { PdfService } from '@design.estate/dees-document/node';

// Browser web components
import '@design.estate/dees-document/web';

// Shared utilities and types
import { translate, IDocumentSettings } from '@design.estate/dees-document/shared';

// TypeScript interfaces
import type { IDocumentSettings } from '@design.estate/dees-document/interfaces';

Document Components

The framework includes these web components:

Component Description
<dedocument-dedocument> Main document container with pagination
<dedocument-viewer> Document viewer with controls
<dedocument-page> Single A4 page with scaling support
<dedocument-pageheader> Company logo and branding header
<dedocument-letterheader> Sender/recipient addresses
<dedocument-pagecontent> Main content area
<dedocument-pagefooter> Company info and page numbers
<dedocument-contentinvoice> Invoice-specific content layout
<dedocument-paymentcode> EPC QR code for SEPA payments

Draft vs Final Documents

Control document version display:

const invoice = {
  // ... other fields
  versionInfo: {
    type: 'draft', // Shows watermark "DRAFT" across pages
    version: '0.1.0',
  },
};

// For final documents
const invoice = {
  // ... other fields
  versionInfo: {
    type: 'final', // Clean document without watermark
    version: '1.0.0',
  },
};

This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the LICENSE file.

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.

Trademarks

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.

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.

Company Information

Task Venture Capital GmbH Registered at District Court Bremen HRB 35230 HB, Germany

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.

changelog.md for @design.estate/dees-document

2025-12-11 - 2.2.3 - fix(contentinvoice)

Use shared translation.TranslationKey type in DeContentInvoice.translateKey and remove local import

2025-12-11 - 2.2.0 - feat(viewer)

Add pagination metadata and thumbnail offset rendering for viewer thumbnails

2025-12-11 - 2.1.1 - fix(viewer)

Improve sidebar resizing UX and update deps

2025-12-11 - 2.1.0 - feat(viewer)

Add smooth zoom and scroll animations to viewer

2025-12-11 - 2.0.6 - fix(DeDocumentViewer)

Account for toolbar and padding when calculating Fit Page zoom in viewer

2025-12-11 - 2.0.2 - fix(page)

Use theme variables for page styling, make pagecontainer background theme-aware, and use accent background for footer separator

2025-12-10 - 2.0.1 - fix(core)

Migrate file I/O to @push.rocks/smartfs, adopt TC39 decorators v3 accessor in web components, and update docs/tests

2025-12-10 - 2.0.0 - BREAKING CHANGE(build)

Upgrade dependencies and dev tooling; adjust TypeScript config

2025-01-01 - 1.6.11 - fix(license)

2024-12-08 - 1.6.10 - fix(core)

Improve stability and performance of document generation

2024-12-08 - 1.6.9 - fix(contentinvoice.ts)

Improve invoice item layout and fix alignment issues.

2024-12-07 - 1.6.8 - fix(rendering and logging)

Removed debug logging from document rendering process.

2024-12-07 - 1.6.7 - fix(document rendering)

Fixed overflow issues in document and page elements

2024-12-07 - 1.6.6 - fix(page-render)

Fix layout scaling adjustment for page component

2024-12-05 - 1.6.5 - fix(contentinvoice)

Fix VAT group item number formatting and remove custom font style in invoice sums.

2024-12-05 - 1.6.4 - fix(styling)

Consolidated shared styles for consistent font applied across various components.

2024-12-05 - 1.6.3 - fix(ui)

Corrects font family in contentinvoice element.

2024-12-05 - 1.6.2 - fix(translation)

Corrected missing translation keys for VAT short form across multiple languages.

2024-12-05 - 1.6.1 - fix(core)

Ensure consistent project structure and code organization without additional changes.

2024-12-05 - 1.6.0 - feat(documentSettings + translations + vat in itemLines)

Updated dependencies in package.json

2024-12-02 - 1.5.3 - fix(elements)

Update viewer attributes and fix font integration

2024-12-02 - 1.5.2 - fix(workflow)

Corrected Docker image references and package scope in YAML workflows for compatibility.

2024-12-02 - 1.5.1 - fix(package)

Fix duplicate node export in package.json

2024-12-02 - 1.5.0 - feat(core)

Refactor project structure for better modularity and code organization

2024-12-02 - 1.4.0 - feat(translation)

Add French and Italian translations for document interface

2024-12-02 - 1.3.2 - fix(core)

Minor updates and optimizations in the output PDF formatting process.

2024-12-02 - 1.3.1 - fix(documentation)

Updated project description and enhanced documentation in package.json and README

2024-12-02 - 1.3.0 - feat(translation)

Add multi-language support for document translations.

2024-12-01 - 1.2.0 - feat(core)

Enhance document generation capabilities with improved modular structure and extended translation support.

2024-11-30 - 1.1.0 - feat(core)

Enhanced document generation features and added translation capabilities

2024-11-27 - 1.0.103 - fix(DeDocument)

Fix rendering of documents by properly moving new pages back to the document container

2024-11-27 - 1.0.102 - fix(contentinvoice)

Fixed currency display issues in invoice content rendering.

2024-11-27 - 1.0.101 - fix(shared)

Fixed the demo letter item details by replacing currency with position to correctly define the item position.

2024-11-27 - 1.0.100 - fix(core)

Fix issues with PDF service, invoice item positioning, and update package dependencies.

2024-04-20 to 2023-10-16 - 1.0.99 to 1.0.90 - Core Fixes and Documentation Update

Routine updates and fixes with a focus on core improvements and documentation enhancements.