本文整理汇总了PHP中Font::CreateCIDTrueTypeFont方法的典型用法代码示例。如果您正苦于以下问题:PHP Font::CreateCIDTrueTypeFont方法的具体用法?PHP Font::CreateCIDTrueTypeFont怎么用?PHP Font::CreateCIDTrueTypeFont使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Font
的用法示例。
在下文中一共展示了Font::CreateCIDTrueTypeFont方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
function main()
{
global $input_path, $output_path;
PDFNet::Initialize();
$doc = new PDFDoc();
$builder = new ElementBuilder();
$writer = new ElementWriter();
// Start a new page ------------------------------------
$page = $doc->PageCreate(new Rect(0.0, 0.0, 612.0, 794.0));
$writer->Begin($page);
// begin writing to this page
// Embed and subset the font
$font_program = $input_path . "ARIALUNI.TTF";
if (!file_exists($font_program)) {
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$font_program = "C:/Windows/Fonts/ARIALUNI.TTF";
echo nl2br("Note: Using ARIALUNI.TTF from C:/Windows/Fonts directory.\n");
} else {
echo nl2br("Error: Cannot find ARIALUNI.TTF.\n");
exit(1);
}
}
$fnt = Font::CreateCIDTrueTypeFont($doc->GetSDFDoc(), $font_program, true, true);
$element = $builder->CreateTextBegin($fnt, 1.0);
$element->SetTextMatrix(10.0, 0.0, 0.0, 10.0, 50.0, 600.0);
$element->GetGState()->SetLeading(2);
// Set the spacing between lines
$writer->WriteElement($element);
// Hello World!
$hello = array('H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd', '!');
$writer->WriteElement($builder->CreateUnicodeTextRun($hello, count($hello)));
$writer->WriteElement($builder->CreateTextNewLine());
// Latin
$latin = array('a', 'A', 'b', 'B', 'c', 'C', 'd', 'D', 0x45, 0x46, 0xc0, 0xc1, 0xc2, 0x143, 0x144, 0x145, 0x152, '1', '2');
$writer->WriteElement($builder->CreateUnicodeTextRun($latin, count($latin)));
$writer->WriteElement($builder->CreateTextNewLine());
// Greek
$greek = array(0x39e, 0x39f, 0x3a0, 0x3a1, 0x3a3, 0x3a6, 0x3a8, 0x3a9);
$writer->WriteElement($builder->CreateUnicodeTextRun($greek, count($greek)));
$writer->WriteElement($builder->CreateTextNewLine());
// Cyrillic
$cyrillic = array(0x409, 0x40a, 0x40b, 0x40c, 0x40e, 0x40f, 0x410, 0x411, 0x412, 0x413, 0x414, 0x415, 0x416, 0x417, 0x418, 0x419);
$writer->WriteElement($builder->CreateUnicodeTextRun($cyrillic, count($cyrillic)));
$writer->WriteElement($builder->CreateTextNewLine());
// Hebrew
$hebrew = array(0x5d0, 0x5d1, 0x5d3, 0x5d3, 0x5d4, 0x5d5, 0x5d6, 0x5d7, 0x5d8, 0x5d9, 0x5da, 0x5db, 0x5dc, 0x5dd, 0x5de, 0x5df, 0x5e0, 0x5e1);
$writer->WriteElement($builder->CreateUnicodeTextRun($hebrew, count($hebrew)));
$writer->WriteElement($builder->CreateTextNewLine());
// Arabic
$arabic = array(0x624, 0x625, 0x626, 0x627, 0x628, 0x629, 0x62a, 0x62b, 0x62c, 0x62d, 0x62e, 0x62f, 0x630, 0x631, 0x632, 0x633, 0x634, 0x635);
$writer->WriteElement($builder->CreateUnicodeTextRun($arabic, count($arabic)));
$writer->WriteElement($builder->CreateTextNewLine());
// Thai
$thai = array(0xe01, 0xe02, 0xe03, 0xe04, 0xe05, 0xe06, 0xe07, 0xe08, 0xe09, 0xe0a, 0xe0b, 0xe0c, 0xe0d, 0xe0e, 0xe0f, 0xe10, 0xe11, 0xe12);
$writer->WriteElement($builder->CreateUnicodeTextRun($thai, count($thai)));
$writer->WriteElement($builder->CreateTextNewLine());
// Hiragana - Japanese
$hiragana = array(0x3041, 0x3042, 0x3043, 0x3044, 0x3045, 0x3046, 0x3047, 0x3048, 0x3049, 0x304a, 0x304b, 0x304c, 0x304d, 0x304e, 0x304f, 0x3051, 0x3051, 0x3052);
$writer->WriteElement($builder->CreateUnicodeTextRun($hiragana, count($hiragana)));
$writer->WriteElement($builder->CreateTextNewLine());
// CJK Unified Ideographs
$cjk_uni = array(0x5841, 0x5842, 0x5843, 0x5844, 0x5845, 0x5846, 0x5847, 0x5848, 0x5849, 0x584a, 0x584b, 0x584c, 0x584d, 0x584e, 0x584f, 0x5850, 0x5851, 0x5852);
$writer->WriteElement($builder->CreateUnicodeTextRun($cjk_uni, count($cjk_uni)));
$writer->WriteElement($builder->CreateTextNewLine());
// Simplified Chinese
$chinese_simplified = array(0x4e16, 0x754c, 0x60a8, 0x597d);
$writer->WriteElement($builder->CreateUnicodeTextRun($chinese_simplified, count($chinese_simplified)));
$writer->WriteElement($builder->CreateTextNewLine());
// Finish the block of text
$writer->WriteElement($builder->CreateTextEnd());
$writer->End();
// save changes to the current page
$doc->PagePushBack($page);
$doc->Save($output_path . "unicodewrite.pdf", SDFDoc::e_remove_unused | SDFDoc::e_hex_strings);
echo "Done. Result saved in unicodewrite.pdf...\n";
}