Tradedoc: PDF generation for trade documents
The goal of this module is to easily generate PDF's like invoices, receipts, packing lists, etc.
Supported:
- Invoice
- Proforma Invoice
- Packing List
Features:
- Translation*
- English (
Language::English) - German (
Language::German) - French (
Language::French) - Spanish (
Language::Spanish) - Portuguese (
Language::Portuguese) - Thai (
Language::Thai) - Italian (
Language::Italian) - Add or overwrite via Dictionary
- English (
- Customization
*Machine translation: If something's off, please provide a PR, or overwrite it with your own dictionary.
Generate examples
With language support:
Usage
Generate PDF's
Refer to src/bin/example.rs for usage examples.
// Invoice
let pdf_data = generate_pdf_invoice?;
// Proforma Invoice
let pdf_data = generate_pdf_proforma_invoice?;
// Packing List
let pdf_data = generate_pdf_packing_list?;
This is a bit verbose, but allows support for more document types in the future.
Fonts
The following fonts are embedded for ease of use:
NotoSans-RegularNotoSans-SemiBoldNotoSansThai-RegularNotoSansThai-SemiBold
You can also provide custom fonts by passing font bytes to the custom_font_normal and custom_font_bold parameters. Pass None to use the default embedded fonts.
Logo Support
All document types support optional logo placement in the top-right corner:
- Supported formats: PNG, SVG
- Usage: Pass logo bytes via the
logo_dataparameter - Position: Top-right corner of the document
- Size: Automatically scaled to fit (80mm × 24mm)
- Embedding: Use
include_bytes!()to embed logo in binary
Example:
const LOGO: & = include_bytes!;
let pdf_data = generate_pdf_invoice?;
Development
Compile and start server:
Clippy: