.gitea/workflows | ||
.vscode | ||
test | ||
ts | ||
.gitignore | ||
changelog.md | ||
npmextra.json | ||
package.json | ||
pnpm-lock.yaml | ||
readme.hints.md | ||
readme.md | ||
tsconfig.json |
@fin.cx/xinvoice
a module for working with xinvoice packages.
Install
To install @fin.cx/xinvoice
, you'll need npm (Node Package Manager). Run this command in your terminal:
npm install @fin.cx/xinvoice
This command fetches the xinvoice package from the npm registry and installs it in your project.
Usage
The @fin.cx/xinvoice
module is designed to work with xinvoice packages, specifically aimed at managing invoices with ease. This document will guide you through using all the features offered by the module, ensuring you can effectively incorporate it into your projects.
Getting Started with ESM and TypeScript
To use @fin.cx/xinvoice
in a TypeScript project, first, make sure you have configured TypeScript to support ECMAScript modules (ESM). Here's a basic tsconfig.json
for reference:
{
"compilerOptions": {
"module": "ESNext",
"target": "ESNext",
"moduleResolution": "node",
"strict": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"outDir": "./dist",
"types": ["node"]
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}
Importing the Module
With TypeScript configured, import the module into your project using ESM syntax:
import { XInvoice } from '@fin.cx/xinvoice';
Working with Invoices
The core functionality revolves around creating and managing XInvoice instances, which represent your invoices. Let's dive into how we can create and manipulate these instances.
Creating an XInvoice Instance
To create a new instance of XInvoice
, you'll need a PDF path, an XML path (which contains the invoice data), and an output path where the processed file will be saved:
const pdfPath = './path/to/your/invoice.pdf';
const xmlPath = './path/to/your/invoice.xml';
const outputPath = './path/to/save/processed_invoice.pdf';
const xInvoice = new XInvoice(pdfPath, xmlPath, outputPath);
Embedding XML into a PDF
One of the key features is embedding XML data into a PDF. This is crucial for ensuring that your invoice contains all necessary data in a format that's both human-readable and machine-processable. Here’s how to embed XML into a PDF:
await xInvoice.embedXml();
This method asynchronously processes the PDF and XML files, embedding the XML data into the PDF. Upon completion, it saves the modified PDF to the specified outputPath
.
Parsing XML to Create an Invoice Object
While the provided example doesn't directly expose a parsing method, @fin.cx/xinvoice
is designed to facilitate the extension and customization of such functionalities. If parsing from XML to a structured invoice object is necessary, consider implementing a parser that utilizes the interfaces provided by the module.
For illustrative purposes, if there was a method parseXmlToInvoice(xmlContent: string)
within XInvoice
, it could be used like this:
const xmlContent = `<Your XML content here>`;
const invoiceData = xInvoice.parseXmlToInvoice(xmlContent);
console.log(invoiceData);
Conclusion
The @fin.cx/xinvoice
module provides a foundational framework for working with xinvoices, focusing on embedding XML data into PDFs and facilitating the potential parsing of XML to structured invoice data. Its usage in a TypeScript environment ensures type safety and enhances the development experience.
This guide covered installing the module, setting up a TypeScript project to use ESM syntax, creating an XInvoice
instance, and embedding XML into PDFs. With these capabilities, @fin.cx/xinvoice
is a robust tool for managing xinvoice packages within your application.
License and Legal Information
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 file within this repository.
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 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.
Company Information
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
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.