枚举参考
TCPDF-Next 使用 PHP 8.1+ 原生枚举(Backed Enum)来表达所有有限选项集合。所有枚举定义于 TcpdfNext\Contracts 命名空间。
Orientation — 页面方向
php
enum Orientation: string
{
case Portrait = 'portrait'; // 纵向
case Landscape = 'landscape'; // 横向
}用于 Document::addPage() 与 Document::setOrientation()。
Alignment — 文字对齐
php
enum Alignment: string
{
case Left = 'L'; // 左对齐
case Center = 'C'; // 居中对齐
case Right = 'R'; // 右对齐
case Justify = 'J'; // 两端对齐
}用于 cell() 与 multiCell() 的 align 参数。
OutputDestination — 输出目的地
php
enum OutputDestination: string
{
case Inline = 'I'; // 直接输出到浏览器(inline)
case Download = 'D'; // 强制下载
case File = 'F'; // 保存到服务器文件
case String = 'S'; // 返回为字符串
}用于 Document::output() 方法。
SignatureLevel — PAdES 签名等级
php
enum SignatureLevel: string
{
case PAdES_B_B = 'B-B'; // 基本签名
case PAdES_B_T = 'B-T'; // 含 RFC 3161 时间戳
case PAdES_B_LT = 'B-LT'; // 含验证数据(OCSP / CRL)
case PAdES_B_LTA = 'B-LTA'; // 长期保存(含文档时间戳)
}用于 Document::sign() 的 level 参数。
BlendMode — 混合模式
php
enum BlendMode: string
{
case Normal = 'Normal';
case Multiply = 'Multiply';
case Screen = 'Screen';
case Overlay = 'Overlay';
case Darken = 'Darken';
case Lighten = 'Lighten';
case ColorDodge = 'ColorDodge';
case ColorBurn = 'ColorBurn';
case HardLight = 'HardLight';
case SoftLight = 'SoftLight';
case Difference = 'Difference';
case Exclusion = 'Exclusion';
}用于图形透明度配置中的色彩混合计算。
BarcodeType — 一维条码类型
php
enum BarcodeType: string
{
case Code128 = 'C128';
case Code128A = 'C128A';
case Code128B = 'C128B';
case Code128C = 'C128C';
case Code39 = 'C39';
case Code39Ext = 'C39E';
case EAN8 = 'EAN8';
case EAN13 = 'EAN13';
case UPCA = 'UPCA';
case UPCE = 'UPCE';
case I25 = 'I25'; // Interleaved 2 of 5
case S25 = 'S25'; // Standard 2 of 5
case Codabar = 'CODABAR';
case MSI = 'MSI';
case Postnet = 'POSTNET';
case Pharma = 'PHARMA';
}用于 Document::barcode1D() 的 type 参数。
Barcode2DType — 二维条码类型
php
enum Barcode2DType: string
{
case QRCode = 'QRCODE';
case DataMatrix = 'DATAMATRIX';
case PDF417 = 'PDF417';
}FormFieldType — 表单字段类型
php
enum FormFieldType: string
{
case Text = 'text';
case CheckBox = 'checkbox';
case Radio = 'radio';
case ComboBox = 'combobox';
case ListBox = 'listbox';
case PushButton = 'pushbutton';
case Signature = 'signature';
}PdfAVersion — PDF/A 合规等级
php
enum PdfAVersion: string
{
case PdfA4 = 'PDF/A-4'; // 基本合规(无需 Tagged PDF)
case PdfA4f = 'PDF/A-4f'; // 允许嵌入任意格式文件
}用于 Document::setPdfACompliance()。
FontType — 字体类型
php
enum FontType: string
{
case TrueType = 'TrueType';
case OpenType = 'OpenType';
case Type1 = 'Type1'; // 标准 14 字体
case CIDFont = 'CIDFont'; // CID 字体(CJK)
}ColorSpace — 色彩空间
php
enum ColorSpace: string
{
case DeviceRGB = 'DeviceRGB';
case DeviceCMYK = 'DeviceCMYK';
case DeviceGray = 'DeviceGray';
case ICCBased = 'ICCBased';
case CalRGB = 'CalRGB';
case CalGray = 'CalGray';
case Lab = 'Lab';
}TextRenderMode — 文字渲染模式
php
enum TextRenderMode: int
{
case Fill = 0; // 填充(默认)
case Stroke = 1; // 描边
case FillAndStroke = 2; // 填充加描边
case Invisible = 3; // 隐形(OCR 文字层)
}用于 Document::setTextRenderMode()。
TextDirection — 文字方向
php
enum TextDirection: string
{
case LTR = 'ltr'; // 左到右
case RTL = 'rtl'; // 右到左
case Auto = 'auto'; // 自动检测(默认)
}PageLayout — 页面排版
php
enum PageLayout: string
{
case SinglePage = 'SinglePage'; // 单页
case OneColumn = 'OneColumn'; // 单栏连续
case TwoColumnLeft = 'TwoColumnLeft'; // 双栏,奇数页在左
case TwoColumnRight = 'TwoColumnRight'; // 双栏,奇数页在右
case TwoPageLeft = 'TwoPageLeft'; // 双页,奇数页在左
case TwoPageRight = 'TwoPageRight'; // 双页,奇数页在右
}用于 ViewerPreferences::setPageLayout()。
PageMode — 打开模式
php
enum PageMode: string
{
case UseNone = 'UseNone'; // 不显示面板
case UseOutlines = 'UseOutlines'; // 显示书签面板
case UseThumbs = 'UseThumbs'; // 显示缩略图面板
case FullScreen = 'FullScreen'; // 全屏模式
case UseOC = 'UseOC'; // 显示图层面板
case UseAttachments = 'UseAttachments'; // 显示附件面板
}StreamFilter — 流过滤器
php
enum StreamFilter: string
{
case FlateDecode = 'FlateDecode'; // zlib 压缩
case ASCIIHexDecode = 'ASCIIHexDecode'; // 十六进制编码
case ASCII85Decode = 'ASCII85Decode'; // ASCII85 编码
case DCTDecode = 'DCTDecode'; // JPEG
case JPXDecode = 'JPXDecode'; // JPEG 2000
case CCITTFaxDecode = 'CCITTFaxDecode'; // CCITT 传真
}HashAlgorithm — 哈希算法
php
enum HashAlgorithm: string
{
case SHA256 = 'sha256';
case SHA384 = 'sha384';
case SHA512 = 'sha512';
}用于数字签名的摘要计算。
Permission — 文件权限
php
enum Permission: int
{
case Print = 4;
case Modify = 8;
case Copy = 16;
case Annotate = 32;
case FillForms = 256;
case ExtractForAccessibility = 512;
case Assemble = 1024;
case PrintHighQuality = 2048;
}用于 Document::encrypt() 的 permissions 数组。多个权限以数组传入:
php
$doc->encrypt(
userPassword: '',
ownerPassword: 'admin',
permissions: [Permission::Print, Permission::Copy]
);AFRelationship — 关联文件关系
php
enum AFRelationship: string
{
case Source = 'Source';
case Data = 'Data';
case Alternative = 'Alternative';
case Supplement = 'Supplement';
case EncryptedPayload = 'EncryptedPayload';
case FormData = 'FormData';
case Schema = 'Schema';
case Unspecified = 'Unspecified';
}用于 PDF 2.0 关联文件(AssociatedFile)的 relationship 属性。
PrintScaling — 打印缩放
php
enum PrintScaling: string
{
case None = 'None'; // 不缩放
case AppDefault = 'AppDefault'; // 应用程序默认
}Duplex — 双面打印
php
enum Duplex: string
{
case Simplex = 'Simplex'; // 单面
case DuplexFlipShortEdge = 'DuplexFlipShortEdge'; // 双面,短边翻转
case DuplexFlipLongEdge = 'DuplexFlipLongEdge'; // 双面,长边翻转
}ReadingDirection — 阅读方向
php
enum ReadingDirection: string
{
case L2R = 'L2R'; // 左到右(默认)
case R2L = 'R2L'; // 右到左
}用于 ViewerPreferences::setReadingDirection()。
相关页面
- Document API — 使用枚举作为方法参数的完整说明
- 接口参考 — 接口中引用的枚举类型
- 值对象 API — 值对象与枚举的搭配使用