rospdf/pdf-php

R&OS Pdf类支持在不安装任何额外模块或扩展的情况下创建PDF文档。

0.12.67 2023-04-20 20:52 UTC

README

Latest Stable Version Total Downloads Daily Downloads License Build Donations Badge

ros.jpg

这是从之前存储在sourceforge.net/projects/pdf-php/上的R&OS PHP Pdf类官方GIT克隆的版本。现在开发将在这里进行。

R&OS Pdf类用于使用PHP生成PDF文档,无需安装任何额外模块或扩展。它包含一个名为"Cpdf.php"的基类以及一个名为"Cezpdf.php"的辅助类,用于生成表格、添加背景并提供分页。

文档网站贡献

特性

  • 快速且易于使用
  • 支持扩展类
  • Unicode和ANSI格式文本
  • 自定义TTF字体和字体子集(版本>=0.11.8)
  • 自动页面和行中断
  • 文本对齐(左、右、居中、两端对齐)
  • 链接XObjects
  • 内部和外部链接
  • 使用gzcompress进行压缩
  • 加密40位,自PDF 1.4起支持128位
  • 支持JPEG、PNG和GIF图像(部分)
  • 模板支持

安装

手动下载

打开版本页面,下载最新版本。

将存档解压到您的项目目录中

通过git克隆

您也可以使用git通过以下命令安装:

git clone https://github.com/rospdf/pdf-php.git
git checkout <latest-version>

通过composer安装

此库也位于依赖管理器composer上 - https://packagist.org.cn/packages/rospdf/pdf-php

请按照此处的步骤进行安装。完成后,只需一个简单的命令即可获取包rospdf/pdf-php的所有依赖项。

./composer.phar require rospdf/pdf-php

有关如何使用composer的更多详细信息,请参阅文档 - https://getcomposer.org.cn/doc/

示例

<?php

include 'src/Cezpdf.php'; // Or use 'vendor/autoload.php' when installed through composer

// Initialize a ROS PDF class object using DIN-A4, with background color gray
$pdf = new Cezpdf('a4','portrait','color',[0.8,0.8,0.8]);
// Set pdf Bleedbox
$pdf->ezSetMargins(20,20,20,20);
// Use one of the pdf core fonts
$mainFont = 'Times-Roman';
// Select the font
$pdf->selectFont($mainFont);
// Define the font size
$size=12;
// Modified to use the local file if it can
$pdf->openHere('Fit');

// Output some colored text by using text directives and justify it to the right of the document
$pdf->ezText("PDF with some <c:color:1,0,0>blue</c:color> <c:color:0,1,0>red</c:color> and <c:color:0,0,1>green</c:color> colours", $size, ['justification'=>'right']);
// Output the pdf as stream, but uncompress
$pdf->ezStream(['compress'=>0]);
?>

贡献者

ole1986是主要开发者。

查看完整的贡献者列表