PHP code example of xiansin / php-seal-util

1. Go to this page and download the library: Download xiansin/php-seal-util library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xiansin / php-seal-util example snippets



use Xiansin\SealUtil\SealUtil;
use Xiansin\SealUtil\SealConfiguration;
use Xiansin\SealUtil\SealFont;
use Xiansin\SealUtil\SealCircle;

try {
    //主文字
    $configuration = new SealConfiguration();

    $mainFont = new SealFont();
    $mainFont->setFontSize(54)
        ->setFontFamily(SealFont::FONT_FAMILY_FANGSONG_CHANG)
        ->setFontText('xxxx专用章');

    //副文字
    $viceFont = new SealFont();
    $viceFont->setBold(true)
        ->setFontFamily(SealFont::FONT_FAMILY_KAI)
        ->setFontText('9006865154564')
        ->setFontSize(12);

    //
    $titleFont = new SealFont();
    $titleFont->setBold(true)
        ->setFontFamily(SealFont::FONT_FAMILY_FANGSONG_CHANG)
        ->setFontText('财务专用章')
        ->setFontSize(28);


    $centerFont = new SealFont();
    $centerFont->setBold(true)
        ->setFontFamily(SealFont::FONT_FAMILY_SONG)
        ->setFontText("★")
        ->setFontSize(100);


    $configuration
        ->setImageSize(480)
        ->setBackgroudColor(0xFF0000)
        ->setMainFont($mainFont)
        ->setViceFont($viceFont)
        ->setTitleFont($titleFont)
        ->setCenterFont($centerFont)
        ->setBorderCircle(new SealCircle(15, 400, 240))
//        ->setBorderInnerCircle(new SealCircle(2 , 400, 400))
//        ->setInnerCircle(new SealCircle(2 , 300, 300))
        ;

    SealUtil::buildAndStoreSeal($configuration, __DIR__ . '/output/公章1.png');
    echo "公章1已生成: " . __DIR__ . "/output/公章1.png\n";
} catch (\Throwable $e) {
    echo "公章1生成失败: " . $e->getMessage() . "\n";
}