komune3/pdftemplate

该软件包最新版本(dev-master)没有可用的许可信息。

ODT 转 PDF 转换库

dev-master 2021-12-06 08:23 UTC

This package is auto-updated.

Last update: 2024-09-06 14:42:39 UTC


README

PDFTemplate

PDFTemplate - 从 ODT 文件创建 PDF 并替换占位符/变量

本模块提供了一种简单的方法从 OpenDocument (.odt) 模板创建 PDF 文件。神奇之处在于:每个模板都可以包含各种占位符/变量,这些变量可以轻松替换。

此模块集成了免费的 www.pdftemplate.eu 服务。无需注册!

通过 composer 安装

composer require kommune3/pdftemplate

简单示例

<?php
use PDFTemplate\PDFTemplate;

$pdf = new PDFTemplate();

// Basic settings
$pdf->setFilename('example.pdf');
$pdf->setTemplate('odt/example.odt'); // Path to your local Open Document Template
$pdf->setDestination('local/folder'); // Set the destination where the generated PDF should be stored

// Set some vars
$pdf->addVar('first_name', 'John');
$pdf->addVar('last_name', 'Doe');

// Add a row
$row = new PDFTemplateRow('demoitems');
$row->addVar('position', '1');
$row->addVar('title', 'This is a title');
$row->addVar('quantity', '5');
$row->addVar('price', '15.99');

$pdf->addRow($row);

// Finally create the PDF
$pdf->createPDF();