set_option("errorpolicy=return"); $p->set_option("stringformat=utf8"); $p->set_option("searchpath={" . $searchpath . "}"); if ($p->begin_document($outfile, "") == 0) throw new Exception("Error: " . $p->get_errmsg()); $p->set_info("Creator", "PDFlib Cookbook"); $p->set_info("Title", $title ); $font = $p->load_font("Helvetica", "winansi", ""); if ($font == 0) throw new Exception("Error: " . $p->get_errmsg()); /* ページを始める */ $p->begin_page_ext(0, 0, " width=a4.width height=a4.height"); /* コンボボックスのタイトルを出力する */ $p->setfont($font, 14); $p->fit_textline("Choose a size from the list or enter an individual " . "value:", $llx, $lly, ""); $lly-=30; /* コンボボックスタイプのフォームフィールドを作成する * ボックスの背景をライトグレーで指定する * (backgroundcolor={gray 0.9}) * 境界線色にグレーを指定する * (bordercolor={gray 0.7}). * コンボボックスのアイテムの値を指定する(itemnamelist={0 1 2 3 4}). * コンボボックスのラベルを指定する(itemtextlist={...}). * リストアイテムの初期値を指定する(currentvalue=4). * ユーザーが項目を変更することを許可する (editable=true) */ $optlist = "font=" . $font . " fontsize=14 backgroundcolor={gray 0.9} " . "bordercolor={gray 0.7} itemnamelist={0 1 2 3 4} currentvalue=4 " . "itemtextlist={S M L XL XXL} editable=true"; /* リストアイテムと同じ高さでフィールドを作成する */ $p->create_field($llx, $lly, $llx + $width, $lly + $height, "size", "combobox", $optlist); $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=form_combobox.pdf"); print $buf; } catch (PDFlibException $e) { echo("PDFlib exception occurred:\n". "[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " . $e->get_errmsg() . "\n"); exit(1); } catch (Exception $e) { echo($e->getMessage()); exit(1); } $p = 0; ?>