Created
March 30, 2009 10:14
-
-
Save juno/87727 to your computer and use it in GitHub Desktop.
Japanese PDF generate example with PHP and libharu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ドキュメントインスタンスを生成する | |
$doc = new HaruDoc; | |
// 日本語エンコーディングを利用する | |
$doc->useJPEncodings(); | |
// 日本語フォントを利用する | |
$doc->useJPFonts(); | |
// ドキュメントに新しいページを追加する | |
$page = $doc->addPage(); | |
// ページのサイズと向きを設定する | |
$page->setSize(HaruPage::SIZE_A4, HaruPage::LANDSCAPE); | |
// MSゴシックをCP932エンコーディングで利用する | |
$font = $doc->getFont('MS-Gothic', '90ms-RKSJ-H'); | |
// フォントのサイズを設定する | |
$page->setFontAndSize($font, 60); | |
// 塗の色を設定する | |
$page->setRGBFill(0, 0, 0); | |
// 文字を出力する | |
$page->beginText(); | |
$page->textOut(210, 270, mb_convert_encoding('テストです。', 'SJIS-win', 'UTF-8')); | |
$page->endText(); | |
// 結果をPDFファイルに保存する | |
$doc->save('./test.pdf'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment