Giter Site home page Giter Site logo

vdejager / templated-docs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jptd/templated-docs

0.0 0.0 0.0 160 KB

Generate PDF, MS Word and Excel documents from templates in Django

License: MIT License

Makefile 6.99% Shell 3.72% Python 83.89% HTML 5.40%

templated-docs's Introduction

Templated-docs

Documentation Status Dependencies

Generate templated documents within Django in any format supported by LibreOffice: texts, spreadsheets, presentations etc.

Requirements

  • Python 2.7 or 3.4+
  • Django >= 1.8
  • A recent LibreOffice version (>=4.3.0) supporting LibreOfficeKit API.

Example usage

Create a sample.odt document (make sure it's in OpenDocument format) and put it in your Django templates folder. It should look something like this:

https://github.com/kiawin/templated-docs/raw/master/docs/document-template.png

Then write a view to generate documents from this template:

from templated_docs import fill_template
from templated_docs.http import FileResponse

def get_document(request):
    """
    A view to get a document filled with context variables.
    """
    context = {'user': request.user}  # Just an example

    filename = fill_template('sample.odt', context, output_format='pdf')
    visible_filename = 'greeting.pdf'

    return FileResponse(filename, visible_filename)

Navigate to the url your view is connected to, and you'll see a rendered and converted document:

https://github.com/kiawin/templated-docs/raw/master/docs/generated-document.png

For more examples, see the examples/ subfolder in the repository. More detailed documentation is available on https://templated-docs.readthedocs.io.

Credits

Templated-docs was written by Alex Morozov.

As the repository is left idle for 2 years, Sian Lerk Lau has forked and resume the task of updating the module.

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

templated-docs's People

Contributors

alexmorozov avatar kiawin avatar shinning91 avatar willycahyadi avatar dependabot-preview[bot] avatar dudanogueira avatar

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.