中文文档 | English
PolyContract Engine is a highly extensible, programmatic, and modular multilingual legal contract rendering engine built natively with LuaLaTeX.
Designed specifically to serve as the document-generation backend for web applications (frontend/backend), it cleanly decouples contract data from presentation. It aims to support infinite contract types (Rental, NDA, Employment) and limitless languages in professional side-by-side or single-column formats.
- JSON Driven Web Architecture: Your APIs simply push a
data.jsonconfiguration payload. No messy string-templating or RegEx hacking needed; Lua bridges the web data directly into the LaTeX typesetting environment. - Dynamic Modular Expansion: Built to eventually support hundreds of modular clauses (
modules/). The engine executesloader.luadirectly via\directluaat compilation to dynamically load, translate, and loop through data objects (e.g., arrays of landlords, tenants, or bespoke clauses). - Enterprise Internationalization: Backed by
polyglossiaandparacol, it flawlessly renders complex legal documents in multilingual side-by-side layouts tailored for international agreements. - Immaculate Zero-Debris Builds: The sophisticated
build.shscript parses the JSON payload to dynamically name the output file (e.g.,Contract_Taylor_Swift.pdf) and securely sandboxes all intensive LaTeX auxiliary artifacts into adist/directory.
- Expanded Contract Library: Adding Non-Disclosure Agreements (NDAs), Employment Contracts, and Sales Agreements.
- REST API Wrapper: A lightweight backend (Node/Python) to securely receive JSON, trigger the
Makefile, and return the generated PDF stream. - Full Web Client: A complete React/Vue frontend for users to fill forms explicitly mapping to
data.json.
latex-rental-contract/
├── data.json # Define language, load clauses, and set contract data
├── Makefile # make all -> automatically parses tenant name and executes build
├── src/
│ ├── main.tex # Main modular document
│ ├── loader.lua # Lua logic converting JSON arrays to robust LaTeX commands
│ ├── styles.sty # Font encodings, styling, geometries
│ └── modules/ # Clauses grouped by ISO language codes (cz/en)
└── dist/ # Holds strictly the final rendered PDF (Gitignored)
You need a full TeX distribution equipped with LuaLaTeX.
- macOS:
brew install --cask mactexor via MacPortssudo port install texlive-luatex - Linux:
sudo apt install texlive-full
- Provide your web client data or manually edit
data.json. - Open terminal in the project root:
make clean
make all- Read the output pdf inside
dist/Contract_<TenantName>.pdf!
This project is licensed under the MIT License.
Disclaimer: The contract templates, clauses, and sample legal documents provided in this repository are for demonstration, formatting, and document automation purposes only. They do not constitute formal legal advice. Contract and rental requirements vary significantly across legal jurisdictions; consult qualified legal counsel before using any generated contracts for binding transactions.
