定制 typesetterio/typesetter 二次开发

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

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

typesetterio/typesetter

最新稳定版本:0.10.1

Composer 安装命令:

composer require typesetterio/typesetter

包简介

The main typesetter service for generating PDFs from Markdown for ebooks.

README 文档

README

License Packagist GitHub Workflow Status

Typesetter

This is the Typesetter main service. This can be used in your own projects directly if you want. You probably want to head over to typesetter-cli though.

Install

This requires PHP 8.1 or above.

composer require typesetterio/typesetter

Usage

Create a config array and pass that to the config maker. Then create a new instance of the Typesetter class. Call the generate method with your config to get a PDF binary return from MPDF.

Example:

$config = [
    'title' => 'Benjamin Button',
    'author' => 'F. Scott Fitzgerald',
    'theme' => 'bb',

    'toc-enabled' => true,
    'toc-links' => true,
    'toc-header' => 'Table of Contents',

    'footer' => '{PAGENO}',

    'markdown-extensions' => ['md', 'markdown'],
    'observers' => [
        new \Typesetterio\Typesetter\Observers\DefaultMarkdownConfiguration(),
        new \Typesetterio\TypesetterCLI\Observers\FirstElementInChapterCSSClass(),
        new \Typesetterio\TypesetterCLI\Observers\BreakToPageBreak(),
        new \Typesetterio\TypesetterCLI\Observers\Credits(),
    ],
];

$config = new \Typsetterio\Typesetter\Config($config);
$service = new \Typesetterio\Typesetter\Typesetter();
$pdfContent = $service->generate($config);
file_put_contents('my-pdf.pdf', $pdfContent);

To learn more, please check out the documentation. This details configuration, customization, themes and cover generation, observers, listeners and more.

Credits

This was heavily influenced by the Ibis project but is a complete rewrite.

This package stands on the shoulders of giants like MPDF, some parts of Laravel and also the League Commonmark library.

Aaron Saray is the primary author and maintainer.

统计信息

  • 总下载量: 703
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 9
  • 点击次数: 2
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 9
  • Watchers: 1
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-30