tecnickcom / TCPDF

Official clone of PHP library to generate PDF documents and barcodes
https://tcpdf.org
Other
4.12k stars 1.51k forks source link

Special font (⸧) error using writeHtml write error: Undefined array key 11815 #728

Open LiuShuaiaCai opened 2 months ago

LiuShuaiaCai commented 2 months ago

Use some special characters: $specialChars="①, √, ≤, ≥, x, ⸷, δ, ∑, ⇌, ①, ②, ③, Å,~, ⊃, ➀, ➁, ➂, ≃, ϶, ś, ś, ⊂, ⧫, ɛ, −, •,", ↔, ő,Đ,ć,Ž,ń,ğ,ę,ż,ϒ, á, ó, š, Å, ñ, ó, ź, é, í, ú, à, è, ì, ò, ù, ê, ↕, I, II, III, IV, V, VI, VII, VIII, IX, Á, í, ó, €, Α,Β,Γ,Δ,Ε,Ζ,Η,Θ,Ι,Κ, Λ, Μ,Ν,Ξ,Ο,Π,Ρ,Σ,Τ,Υ,Φ,Χ,Ψ, Ω, α,β,γ,δ,ε,ζ,η,θ,ι,κ,λ,μ,ν,ξ,ο, π, ρ,ς,σ,τ,υ,φ,χ,ψ,ω, , ϵ,∞,سوریف,نورک,دیفوک,انوروک, ṁ, ṁ, ṁ, ü, ß, ß, ṁ, ṁ, ◻,ɛ,ɔ,‧, ●, ",", ",", ",", ",", ",", ",", ",", ",", ",", ",", ",", ",", ",", ",", ",", ",", ",", ",", ",", ",", ",", ",", ",", ",", ",", ",", ",", ",", ",", ",", ",", ",", ",", ", ց,ē,ū,④,⑤,⑥,ƛ,ň, č, ⇄, ⸧, Å, I, Ẑ, □, ⁝, ⋱, ⧧, ѵ, ‴, Å, ⸧, Å, I, Ẑ, □, ⁝, ⋱, ⧧, ѵ, ‴, Å, ɳ, △, æ, ℃, Å, ◆, ☆, ∈, ∝, Λ, ⁋, (); TCPDF version 6.7.5 error message: Undefined array key 11815 error_file:vendor\tecnickcom\tcpdf\include\tcpdf_fonts.php

image

LiuShuaiaCai commented 2 months ago

// 创建新的 PDF 文档 $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// 设置文档信息 $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Author'); $pdf->SetTitle('Title'); $pdf->SetSubject('Subject'); $pdf->SetKeywords('TCPDF, PDF, example, test, guide');

// 设置默认字体子集 $pdf->setFontSubsetting(true);

// 设置字体 - 使用 DejaVu Sans $pdf->SetFont('dejavusans', '', 12);

// 添加页面 $pdf->AddPage();

// 特殊字符字符串 $specialChars = "①,√,≤,≥,×,√,δ,∑,⇌,①,②,③,Å,~,⊃,➀,➁,➂,≃,∪,϶,∇,ś,≫,⇔,⊂,⧫,ɛ,−,•,↔,ő,Đ,ć,Ž,ń,ğ,ę,ż,ϒ,ć,á,ó,š,å,ñ,ó,ź,é,í,ú,à,è,ì,ò,ù,ê,â,ê,î,↨,С,О,Х,↕,Ⅰ,Ⅱ,Ⅲ,Ⅳ,Ⅴ,Ⅵ,Ⅶ,Ⅷ,Ⅸ,Á,í,ó,€,Α,Β,Γ,Δ,Ε,Ζ,Η,Θ,Ι,Κ,Λ,Μ,Ν,Ξ,Ο,Π,Ρ,Σ,Τ,Υ,Φ,Χ,Ψ,Ω,α,β,γ,δ,ε,ζ,η,θ,ι,κ,λ,μ,ν,ξ,ο,π,ρ,ς,σ,τ,υ,φ,χ,ψ,ω,ª,±,→,↑,↓,←,■,¢,≡,ŷ,′,″,⅓,⅔,≠,○,ş,‖,č,Å,ñ,≈,₂,ϕ,ϋ,ʎ,á,é,ϵ,∞,سوریف,نورک,دیفوک,انوروک,ṁ,İ,ü,Г,ü,ß,◊,◻,ɛ,ɔ,‧,●,《,》,Č,ř,Ʃ,▲,▼,–,ф,ћ,ƞ,∩,∠,❈,ǀ,µ,⊃,Í,Ú,Ф,ḉ,Ω,Ʌ,ℑ,ց,ē,ū,④,①,②,③,⑤,⑥,ƛ,ň,č,⇄,⇌,⸧,Å,и,Ẑ,□,⁝,⋱,⧧,ѵ,‴,⌀,┴,ɳ,△,⊥,℃,ā,◆,☆,∈,∝,∧,⁋,mmm,(";

    $htmlEntities = mb_convert_encoding($specialChars, 'HTML-ENTITIES', 'UTF-8');

// 包含 HTML 标记以应用字体 $html = '' . $htmlEntities . '';

// 写入 HTML 内容 $pdf->writeHTML($html, true, false, true, false, ''); // 关闭并输出 PDF 文档 $pdfLocalPath = storage_path('a.pdf'); $pdf->Output($pdfLocalPath, 'F');