承接 vivutio/pdf-scribe-bundle 相关项目开发

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

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

vivutio/pdf-scribe-bundle

最新稳定版本:v0.1.0-alpha

Composer 安装命令:

composer require vivutio/pdf-scribe-bundle

包简介

Symfony 7/8 bundle for PDF generation using Chrome Headless

README 文档

README

Packagist Version Packagist Downloads License

A Symfony 7/8 bundle for generating PDFs using Chrome Headless. Provides excellent CSS support with the modern Chrome rendering engine.

Installation

composer require vivutio/pdf-scribe-bundle

Configuration

Create config/packages/pdf_scribe.yaml:

pdf_scribe:
    binary_path: '%env(PDF_SCRIBE_BINARY)%'
    timeout: 120
    options:
        print-background: true
        no-pdf-header-footer: true

Add to .env:

# macOS
PDF_SCRIBE_BINARY="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"

# Linux
PDF_SCRIBE_BINARY=/usr/bin/chromium-browser

Usage

use Vivutio\PdfScribeBundle\Contract\PdfGeneratorInterface;

class InvoiceController extends AbstractController
{
    public function download(Invoice $invoice, PdfGeneratorInterface $pdf): Response
    {
        $html = $this->renderView('invoice/pdf.html.twig', [
            'invoice' => $invoice,
        ]);

        $content = $pdf->fromHtml($html);

        return new Response($content, 200, [
            'Content-Type' => 'application/pdf',
            'Content-Disposition' => 'attachment; filename="invoice.pdf"',
        ]);
    }
}

API

PdfGeneratorInterface

  • fromHtml(string $html, array $options = []): string - Generate PDF from HTML string
  • fromUrl(string $url, array $options = []): string - Generate PDF from URL
  • saveFromHtml(string $html, string $outputPath, array $options = []): void - Save PDF from HTML to file
  • saveFromUrl(string $url, string $outputPath, array $options = []): void - Save PDF from URL to file

Options

Option Type Description
print-background bool Print background graphics
no-pdf-header-footer bool Remove default header/footer
landscape bool Landscape orientation
scale float Scale factor (0.1 to 2.0)

CSS @page Rules

Control page size and margins via CSS in your HTML template:

@page {
    size: A4;
    margin: 15mm;
}

@media print {
    body {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

License

MIT

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固