定制 oat-sa/extension-tao-booklet 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

oat-sa/extension-tao-booklet

Composer 安装命令:

composer require oat-sa/extension-tao-booklet

包简介

An extension for TAO to create test booklets (publishable in MS-Word and PDF along with Answer Sheets)

README 文档

README

An extension for TAO to create test booklets (publishable in MS-Word and PDF along with Answer Sheets)

Warning

Due to the move to ES2015, some code might not work on legacy browsers. Especially for code that use to rely on polyfills, like for the Promise. The polyfills are now linked only when the code is bundled, and are not reachable anymore in development mode. For that reason, and because wkhtmltopdf is not supporting ES2015 and requires polyfills, the generation of PDF only works with bundled version (aka production mode).

From version 4.2.0 of taoBooklet, the page rendered to get the PDF will always use bundles transpiled to ES5. This applies no matter if the mode is set to development or production. This implies that any change made to the source code will need to pass trough a re-bundling:

cd tao/views/build
npx grunt taobookletbundle

For version 4.1.1 and older, you still need to activate the production mode as follows:

  • open the config file config/generis.conf.php, and set the constant DEBUG_MODE to false (around line 50):
#mode
define('DEBUG_MODE', false);

Configuration

The file config/taoBooklet/wkhtmltopdf.conf.php contains entries for setting up the tool:

  • 'binary' - The path to the installed binary, usually /usr/local/bin/wkhtmltopdf.
  • 'options' - A set of option for controlling the rendering. See below.

wkhtmltopdf options

Option Description Default value
'header-html' The path to the header template added to each page. 'taoBooklet/views/templates/PrintTest/header.html'
'footer-html' The path to the header template added to each page. 'taoBooklet/views/templates/PrintTest/footer.html'
'margin-bottom' The margin added to top of the page. 10mm
'margin-top' The margin added to bottom of the page. 10mm
'page-size' The page size format: A4, Letter, etc. 'A4'
'orientation' The page orientation: Portrait or Landscape. 'Portrait'
'user-style-sheet' Specify a user style sheet, to load with every page. none

Note: additional options supported by wkhtmltopdf can be added here too. For a complete list, see: https://wkhtmltopdf.org/usage/wkhtmltopdf.txt

Requirements

This extension needs a third-party tool to generate the PDF files. So to be able to generate the booklet, you should install wkhtmltopdf on your server.

If you are using Ubuntu you can use these commands:

sudo apt-get update
sudo apt-get install wkhtmltopdf

However, depending on the version of your system, the installed version of wkhtmltopdf may not fully comply with the requirements, as there is some issues with QT when trying to render header and footers. If you encounter errors when generating the document, you should install the tool using these commands:

wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.jessie_amd64.deb
sudo dpkg -i wkhtmltox_0.12.5-1.jessie_amd64.deb

After that you can use /usr/local/bin/wkhtmltopdf in your configuration

For Debian-based distributions, you may need to do an additional step to install some dependencies:

sudo apt-get update
sudo apt-get install wkhtmltopdf
sudo apt-get install libxrender1 fontconfig xvfb
sudo apt --fix-broken-install

If the previous steps fail, you may try to use a binary, non-packaged distribution instead.

wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
tar xf  wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
cd ./wkhtmltox/bin/
sudo cp -R ./* /usr/bin/
sudo cp -R ./* /usr/local/bin/
wkhtmltopdf -V

Please refer to https://wkhtmltopdf.org/downloads.html for an updated list of wkhtmltopdf packages for Ubuntu and other distributions. You may find a list of source, binary and packages for v0.12.5 at GitHub as well.

Deprecated: Please note that the version 0.12.4 has a bug which was fixed in the version 0.12.5: sometimes footers and headers not provided in the pdf

sudo apt-get update
sudo apt-get install libxrender1 fontconfig xvfb
wget https://downloads.wkhtmltopdf.org/0.12/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz -P /tmp/
cd /usr/share/
sudo tar xf /tmp/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
sudo rm /usr/bin/wkhtmltopdf
sudo ln -s /usr/share/wkhtmltox/bin/wkhtmltopdf /usr/bin/wkhtmltopdf

oat-sa/extension-tao-booklet 适用场景与选型建议

oat-sa/extension-tao-booklet 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13.53k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2015 年 04 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「TAO」 「computer-based-assessment」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 oat-sa/extension-tao-booklet 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 oat-sa/extension-tao-booklet 我们能提供哪些服务?
定制开发 / 二次开发

基于 oat-sa/extension-tao-booklet 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 13.53k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 30
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 44
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-only
  • 更新时间: 2015-04-08