Git Product home page Git Product logo

docnamic's Introduction

Docnamic - The document template engine

Docnamic is a template engine for OpenDocument files (*.odt) based on PHP's DOM and ZIP extensions. My goal is to provide a simple document generation library whose templates can be easily created using standard WYSIWYG OpenDocument software. I am interested if this library is useful for anybody out there and i will appreciate any feedback on Github or via email.

Please note that the public API should not be considered stable yet.

I will add tests once i am sure about the internal class interfaces.

Requirements

  • PHP 5.6 or later
  • DOM extension
  • ZIP extension

Installation

Install this library via composer.

$ composer require mklocke/docnamic

Usage

Have a look at the folder examples which contains examples of how the library should be used.

$renderer = new Renderer();
$renderer->loadTemplate('template.odt')
         ->setData(['foo' => 'bar'])
         ->render('result.odt');

Convert to PDF

The resulting OpenDocument files can be easily converted to PDF using the unoconv CLI tool on most linux distributions.

Installation on Ubuntu: sudo apt-get install unoconv

Convert a ODT file to PDF: unoconv -f pdf -o result.pdf result.odt

FAQ

  • Can i use barcodes or QR Codes?

    Yes, you can by using barcode fonts in your document template. OpenDocument files can have embedded fonts. If you use LibreOffice for creating your document templates, read their help pages regarding Embedding Fonts

  • Can i use nested loops in my document template?

    No, for now nested loops are not supported.

  • Can i use dynamic images?

    No, dynamic images are not supported yet.

  • What about encodings?

    As OpenDocument is a UTF-8-based XML file format, your data should be UTF-8 encoded as well ;)

  • What about i18n or l10n?

    As this is a rather simple template engine, it has no notion of languages, countries or currencies. This has be taken care of the integrating application.

Inspired by

docnamic's People

Contributors

mariusklocke avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

docnamic's Issues

Get all variables

Hi, thanks for the code - really useful and works great. I'm looking for a way to get all variables in a doc. Could you point me in the right direction? Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.