列舉參考
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 — 值物件與列舉的搭配使用