项目作者: videki

项目描述 :
Docx, xlsx template engine and pdf converter to provide enterprise document generation capabilities
高级语言: Java
项目地址: git://github.com/videki/template-utils.git
创建时间: 2019-10-10T19:35:40Z
项目社区:https://github.com/videki/template-utils

开源协议:MIT License

下载


Get The Docs Document Engine

Build
Tests
Sonar Quality Gate Status
Codecov branch

Docx, xlsx template engine and pdf converter to provide enterprise document generation feautures.

The module is a Helm package with a REST API to generate documents from WYSIWYG templates, or template structures with JSON actual data via jsonpath and SpEL expression-like placeholders. The engine core is a java wrapper to other tools integrate their capabilities and can be used with typed DTO-s as a dependency also.

Note:

This project is in incubation phase. Hold on, we will deploy it on Maven Central and ghcr.io as soon as we can.
If you find the functionality covered by the engine useful, please give it a star.

Main features

  • Impersonate simple docx and xlsx documents via pojo data
  • Document generation based on multiple templates for handling complex hand-outs:
    • Fix/optional templates
    • Language dependent templates
    • Copies
    • Multiple value object handling for different data sources (e.g. capability for differentiating officer and customer data)
    • Pdf concatenation for multi-part documents
    • Cover page for multi user environments
    • QR code and picture embedding
    • MS Office editable templates

Upcoming features

  • Template repository handling
    VCS based template store to provide template history
  • Rule based template structure
    Xls based decision table support for template alternatives to provide business editable template sets

Engine details

Inputs:

  • docx
  • xlsx

Output:

  • native
  • pdf (individual/concatenated)

Uses:

  1. for docx templates:
    • docx-stamper (based on docx4j)
  2. for xlsx templates:
    • apache jexl
  3. for pdf generation:
    • apache pdfbox

Usage

Single document

To create a simple document

  1. public OutputStream generateContractDocument() {
  2. MyDTO dto = generateData();
  3. return TemplateServiceRegistry.getInstance().fill("MyTemplate.docx", dto, OutputFormat.PDF);
  4. }

Document structure

  1. # contract_v02.yml
  2. ---
  3. documentStructureId: "109a562d-8290-407d-98e1-e5e31c9808b7"
  4. elements:
  5. - templateElementId:
  6. id: "cover"
  7. templateNames:
  8. hu_HU: "/full-example/01-cover_v03.docx"
  9. defaultLocale: "hu_HU"
  10. count: 1
  11. - templateElementId:
  12. id: "contract"
  13. templateNames:
  14. en: "/full-example/02-contract_v09_en.docx"
  15. hu: "/full-example/02-contract_v09_hu.docx"
  16. defaultLocale: "hu_HU"
  17. count: 1
  18. - templateElementId:
  19. id: "terms"
  20. templateNames:
  21. hu: "/full-example/03-terms_v02.docx"
  22. defaultLocale: "hu_HU"
  23. count: 1
  24. - templateElementId:
  25. id: "conditions"
  26. templateNames:
  27. hu: "/full-example/04-conditions_eco_v11.xlsx"
  28. defaultLocale: "hu_HU"
  29. count: 1
  30. resultMode: "SEPARATE_DOCUMENTS"
  31. outputFormat: "UNCHANGED"
  32. copies: 1

Local build

To compile the project locally some configuration settings are needed:

  • AWS S3 template repository:

    What you will need:
    an AWS account and an S3 bucket.

    Add the environment variables below to the project configuration or shell:

Name Description
GETTHEDOCS_REPO_TEMPLATE_AWS_S3_BUCKETNAME Your test bucket’s name
GETTHEDOCS_REPO_DOCSTRUCTURE_AWS_S3_BUCKETNAME Your test bucket’s name
GETTHEDOCS_REPO_RESULT_AWS_S3_BUCKETNAME Your test bucket’s name
AWS_ACCESS_KEY_ID The AWS access key id for a user having S3 object RW permissions.
AWS_SECRET_ACCESS_KEY The secret key for the access key id

Project tooling

Issue tracking: Get-the-docs project @ Atlassian Jira