PDFlibで著者名、作成者名を指定する方法です。 set_info関数を使います。 Creator, Title, Subject, Authorなどを指定することができます。 詳細は、PDFlib/PDI/PPSリファレンスp.171の表12.1を参照してください。
<?php define('PATH_CMaps', '/usr/local/pdflib7/resource/cmap'); try { $p = new PDFlib(); $p->set_parameter("SearchPath", PATH_CMaps); $p->set_parameter("errorpolicy", "return"); // 文書の作成に使用されたソフトウェア名の設定 $p->set_info("Creator", "PHP with PDFlib"); // タイトルの設定 $p->set_info("Title", "Set Title and AuthorName or so"); // サブタイトルの設定 $p->set_info("Subject", "How to use set_info()"); // 著者名の設定 $p->set_info("Author", "Mr.PDF"); $p->begin_document("", ""); $p->begin_page_ext(0, 0, "width=a4.width height=a4.height"); $font = $p->load_font("HeiseiKakuGo-W5", "UniJIS-UCS2-H", ""); if ($font == 0) { die("Error: " . $p->get_errmsg()); } $p->setfont($font, 36.0); $p->set_text_pos(50, 700); $hello = mb_convert_encoding("こんにちは世界!", "UCS-2LE", "UTF-8"); $str = mb_convert_encoding("(著者名やタイトル名などの設定)", "UCS-2LE", "UTF-8"); $p->show($hello); $p->continue_text($str); $p->end_page_ext(""); $p->end_document(""); $buf = $p->get_buffer(); $len = strlen($buf); header("Content-type: application/pdf"); header("Content-Length: $len"); header("Content-Disposition: inline; filename=set_info.pdf"); print $buf; } catch (PDFlibException $e) { die("PDFlib exception occurred in hello sample:\n" . "[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " . $e->get_errmsg() . "\n"); } catch (Exception $e) { die($e); } $p = 0;
このPDFを見る
codeなにがし::PDFlibで著者名、作成者名を指定する