承接 choowx/satori-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

choowx/satori-php

最新稳定版本:v0.2.3

Composer 安装命令:

composer require choowx/satori-php

包简介

Run Satori — enlightened library to convert HTML and CSS to SVG, using PHP

README 文档

README

Satori

Run Satori — enlightened library to convert HTML and CSS to SVG, using PHP

Latest Version on Packagist Tests Total Downloads

Satori — enlightened library to convert HTML and CSS to SVG.

This package makes it easy to run Satori using PHP.

Installation

You can install the package via composer:

composer require choowx/satori-php

This package relies on the satori and html-react-parser js packages being available on your system. In most cases you can accomplish this by issues these commands in your project.

npm install satori
npm install html-react-parser

Usage

use Choowx\Satori\Satori;

$svg = Satori::html('<div style="color: black">hello, world</div>')->convert();
// $svg = '<svg width="1200" height="630" viewBox="0 0 1200 630" xmlns="http://www.w3.org/2000/svg"><path fill="black"...

The width and height of the svg can be configured:

use Choowx\Satori\Satori;

$svg = Satori::html('<div style="color: black">hello, world</div>')
    ->width(600)
    ->height(315)
    ->convert();
// $svg = '<svg width="600" height="315" viewBox="0 0 600 315"...

Using custom fonts available in the file system:

Satori currently supports three font formats: TTF, OTF and WOFF. Note that WOFF2 is not supported at the moment.

use Choowx\Satori\Font;
use Choowx\Satori\Satori;

$svg = Satori::html('<div style="color: black">hello, world</div>')
    ->withFonts([
        Font::path('/path/to/Roboto-Regular.ttf')
            ->name('Roboto')
            ->weight(400)
            ->style('regular'),
        Font::path('/path/to/Roboto-Bold.ttf')
            ->name('Roboto')
            ->weight(700)
            ->style('bold'),
    ])
    ->convert();

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 512
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 17
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 17
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-01-02