All Projects → shadz3rg → Phpstamp

shadz3rg / Phpstamp

Licence: mit
The XSL-way templating library for MS Office Word DOCX documents.

Projects that are alternatives of or similar to Phpstamp

Docx
Easily generate .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.
Stars: ✭ 2,150 (+1333.33%)
Mutual labels:  microsoft, document, office, word, docx
Etherpad Lite
Etherpad: A modern really-real-time collaborative document editor.
Stars: ✭ 11,937 (+7858%)
Mutual labels:  microsoft, document, word, docx
Documentserver
ONLYOFFICE Document Server is an online office suite comprising viewers and editors for texts, spreadsheets and presentations, fully compatible with Office Open XML formats: .docx, .xlsx, .pptx and enabling collaborative editing in real time.
Stars: ✭ 2,335 (+1456.67%)
Mutual labels:  doc, office, word, docx
Desktopeditors
An office suite that combines text, spreadsheet and presentation editors allowing to create, view and edit local documents
Stars: ✭ 1,008 (+572%)
Mutual labels:  doc, office, word, docx
Js Word
✒️ Word Processing Document Library
Stars: ✭ 1,203 (+702%)
Mutual labels:  doc, xml, word, docx
wordroller
Free Microsoft Word document (aka .docx) processing library for .Net
Stars: ✭ 17 (-88.67%)
Mutual labels:  microsoft, word, docx
eoffice
Export and import graphics and tables to MicroSoft office
Stars: ✭ 19 (-87.33%)
Mutual labels:  microsoft, office, docx
Officeproducer
Produce doc/docx/pdf format from doc/docx template
Stars: ✭ 95 (-36.67%)
Mutual labels:  doc, office, docx
GemBox.Document.Examples
Read, write, convert and print document files (DOCX, DOC, PDF, HTML, XPS, RTF, and TXT) in a simple and efficient way.
Stars: ✭ 53 (-64.67%)
Mutual labels:  word, docx, doc
redmine preview office
Plugin for Redmine. Preview Microsoft Office Documents in Redmine's preview pane
Stars: ✭ 27 (-82%)
Mutual labels:  microsoft, office, docx
markdown-to-document
A Markdown CLI to easily generate HTML documents from Markdown files
Stars: ✭ 28 (-81.33%)
Mutual labels:  word, docx, document
Phpword
A pure PHP library for reading and writing word processing documents
Stars: ✭ 6,017 (+3911.33%)
Mutual labels:  doc, office, docx
Net Core Docx Html To Pdf Converter
.NET Core library to create custom reports based on Word docx or HTML documents and convert to PDF
Stars: ✭ 133 (-11.33%)
Mutual labels:  word, docx, template
report
manually write doc(docx) by OOXML
Stars: ✭ 21 (-86%)
Mutual labels:  word, office, doc
Poi Tl
Generate awesome word(docx) with template
Stars: ✭ 2,306 (+1437.33%)
Mutual labels:  word, docx, template
Docconv
Converts PDF, DOC, DOCX, XML, HTML, RTF, etc to plain text
Stars: ✭ 735 (+390%)
Mutual labels:  xml, word, docx
Documentbuilder
ONLYOFFICE Document Builder is powerful text, spreadsheet, presentation and PDF generating tool
Stars: ✭ 61 (-59.33%)
Mutual labels:  doc, word, docx
Superfileview
基于腾讯浏览服务Tbs,使用X5Webkit内核,实现文件的展示功能,支持多种文件格式
Stars: ✭ 1,115 (+643.33%)
Mutual labels:  doc, word, docx
Docx
Fast and easy to use .NET library that creates or modifies Microsoft Word files without installing Word.
Stars: ✭ 1,288 (+758.67%)
Mutual labels:  office, docx
Onenote
📚 Linux Electron Onenote - A Linux compatible version of OneNote
Stars: ✭ 1,300 (+766.67%)
Mutual labels:  microsoft, office

PHPStamp

Your donations are always appreciated!
Donate

PHPStamp is a simple PHP templating engine for XML-based Microsoft Word documents.
Library aims to provide native XML-way of templating for DOCX documents as an altenative to treating its content as a string for regex replacing, which has a lot of downsides.
Instead it tries to clean messy WYSIWYG-generated code and create reusable XSL stylesheet from document.

Some additional information:
(EN) https://redd.it/30conp
(RU) http://habrahabr.ru/post/244421/

Features

  • Caching XSL template to filesystem for fast document render.
  • Track document mode - generate and cache new template if original document was updated.
  • Configurable brackets for placeholder tags.
  • Basic extension system, which helps generating content blocks such as Cells or ListItems.

Known issues

Values inserted into placeholder tags may be highlighted as incorrect by spellcheck, since library removes language attribute and MS Word tries to check it with system language.

Requirements

Library requires PHP 5.3+ with DOM, XSL and Zip extensions.
Also depends on doctrine2/Lexer package.

Installation

Install with Composer.

composer require shadz3rg/php-stamp

Usage

Template.

alt tag

<?php
    require 'vendor/autoload.php';
    
    use PHPStamp\Templator;
    use PHPStamp\Document\WordDocument;
    
    $cachePath = 'path/to/writable/directory/';
    $templator = new Templator($cachePath);
    
    // Enable debug mode to generate template with every render call.
    // $templator->debug = true;
    
    // Enable track mode to generate template with every original document change.
    // $templator->trackDocument = true;
    
    $documentPath = 'path/to/document.docx';
    $document = new WordDocument($documentPath);
    
    $values = array(
        'library' => 'PHPStamp 0.1',
        'simpleValue' => 'I am simple value',
        'nested' => array(
            'firstValue' => 'First child value',
            'secondValue' => 'Second child value'
        ),
        'header' => 'test of a table row',
        'students' => array(
            array('id' => 1, 'name' => 'Student 1', 'mark' => '10'),
            array('id' => 2, 'name' => 'Student 2', 'mark' => '4'),
            array('id' => 3, 'name' => 'Student 3', 'mark' => '7')
        ),
        'maxMark' => 10,
        'todo' => array(
            'TODO 1',
            'TODO 2',
            'TODO 3'
        )
    );
    $result = $templator->render($document, $values);
    
    // Now you can get template result.
    // 1. HTTP Download
    $result->download();
    
    // Or
    // 2. Save to file
    // $saved = $result->save(__DIR__ . '/static', 'Test_Result1.docx');
    // if ($saved === true) {
    //     echo 'Saved!';
    // }
    
    // Or
    // 3. Buffer output
    // echo $result->output();
Result.

alt tag

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].