defstudio/template-processor
Composer 安装命令:
composer require defstudio/template-processor
包简介
.odt to .odt/.docx/.doc/.pdf template processor and exporter
README 文档
README
lowriter installation on docker
ARG ENABLE_LIBREOFFICE_WRITER=0 RUN if [ ${ENABLE_LIBREOFFICE_WRITER} = 1 ] ; then \ mkdir -p /usr/share/man/man1 \ && mkdir -p /.cache/dconf && chmod -R 777 /.cache/dconf \ && apt-get update \ && apt-get install -y --no-install-recommends openjdk-11-jre-headless \ && apt-get install -y --no-install-recommends libreoffice-writer \ && apt-get install -y --no-install-recommends libreoffice-java-common ;\ fi;
Usage
use DefStudio\TemplateProcessor\Elements\Image;Template::from($dock_template_path) ->compile([ // will replace all instances of ${single_key} with BAR 'single_key' => 'BAR', // and will repeat the block enclosed by ${array_key}[...]${/array_key} 'array_key' => [ ['name' => 'paul', 'age' => '36'], // with the name and age of each element of the array ['name' => 'john', 'age' => '24'], ['name' => 'ringo', 'age' => '48'], ['name' => 'george', 'age' => '22'] ], // will replace an image named ${signature} with the one passed as argument // you can set the image name with [right click on image]→properties→options→Name 'signature' => new Image(path: '/var/www/storage/app/signature.png', keep_ratio: true)) ]) // Each action can be done as a standalone call ->set('single_key', 'Bar') ->clone(block_name: 'users', variable_replacements: [ ['name' => 'paul', 'age' => '36'], ['name' => 'ringo', 'age' => '48'], ['name' => 'george', 'age' => '22'], ]) ->insert_image('signature', new Image(path: '/var/www/storage/app/signature.png', keep_ratio: true)) //add ->to_pdf() to convert to .pdf, otherwise an .odt file will be built ->to_pdf() // stores the document in a file ->store($output_file) // or returns a BinaryFileResponse ->download($dowloaded_file_name)
notes
- template processor tries to cleanup its variables/block identifiers, if it is failing the detection, make sure to select and apply "cancel formatting" to them
defstudio/template-processor 适用场景与选型建议
defstudio/template-processor 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 852 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 02 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 defstudio/template-processor 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 defstudio/template-processor 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 852
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-02-18