Giter Site home page Giter Site logo

opentbsbundle's Introduction

HEAVY WIP: rewriting OpenTBSBundle for Symfony

This is an attempt at rewriting TinyButStrong and its openTDS bundle with more modern code practices.

Originally forked from mbence/opentbs-bundle: https://github.com/mbence/OpenTBSBundle

credits go to Skrol29 and the TinyButStrong team. http://www.tinybutstrong.com/

OpenTBS - create OpenOffice and Ms Office documents with PHP (and Symfony)

Introduction

(Taken from http://www.tinybutstrong.com/plugins/opentbs/tbs_plugin_opentbs.html)

OpenTBS is a PHP tool to produce any OpenOffice and Ms Office documents with templates.

OpenTBS can merge any OpenDocument and Open XML files. It autommatically reconize extensions: odt, ods, odg, odf, odm, odp, ott, ots, otg, otp, docx, xlsx, pptx. In fact it can merge any XML or Text file saved in a zip container (which is the case for both OpenDocuments and OpenXML documents).

What is special to OpenTBS:

  • Design your templates directly with OpenOffice or MS Office.
  • No exe file needed to merge documents.
  • No temporary files needed to merge documents.
  • Output directly as an http download, a new file on the disk, or as a string (for file attachment for example).
  • Works with both PHP 4 and PHP 5.

Versions included

TinyButStrong - 3.10.1

OpenTBS - 1.9.7

Requirements

  • Symfony2
  • PHP needs to be a minimum version of PHP 5.3.2 (for Symfony2)
  • It is better to have the Zlib extension enabled on your PHP installation. If it's not, here is what to do.

Installation

Step 1: Download the bundle using composer

> composer require mbence/opentbs-bundle

Composer will install the bundle to your project's vendor/mbence/opentbs-bundle directory.

Step 2: Enable the bundle in your AppKernel

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new MBence\OpenTBSBundle\OpenTBSBundle(),
    );
}

Now you can use the 'opentbs' service.

Using OpenTBSBundle

First you need to define the variables in your docx template (you can use any other supported document format).

... some text in a word file with a `[client.name]` variable ...

In TBS you always need a variable base client and a variable name name.

Then in your controller you need to get the OpenTBS service, load your template and merge the fields (eg. replace the teplate variables).

    // get the service
    $TBS = $this->get('opentbs');
    // load your template
    $TBS->LoadTemplate('template.docx');
    // replace variables
    $TBS->MergeField('client', array('name' => 'Ford Prefect'));
    // send the file
    $TBS->Show(OPENTBS_DOWNLOAD, 'file_name.docx');

A note for onshow automatic variables: You could define your variables within the onshow base, (like onshow.name), but I would not recommend this practice for it will only work if you use GLOBAL variables.

For more information ...

read the TBS manual at http://www.tinybutstrong.com/manual.php

and the OpenTBS plugin documentation at http://www.tinybutstrong.com/plugins/opentbs/tbs_plugin_opentbs.html

opentbsbundle's People

Contributors

kharhamel avatar marcoleong avatar mbence avatar

Watchers

 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.