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 paper plane model:", $llx, $lly, ""); $lly-=90; /* リストボックスタイプのフォームフィールドを作成する * ボックスの背景をライトグレーで指定する * (backgroundcolor={gray 0.9}) * 境界線色にグレーを指定する * (bordercolor={gray 0.7}). * リストアイテムの値を指定する (itemnamelist={0 1 2 3}). * リストボックスのラベルを指定する (itemtextlist={...}). * 最初の項目にフォーカスを設定する (currentvalue=0). */ $optlist = "font=" . $font . " fontsize=14 backgroundcolor={gray 0.9} " . "bordercolor={gray 0.7} itemnamelist={0 1 2 3} currentvalue=0 " . "itemtextlist={{Long Distance Glider} {Giant Wing} {Cone Head " . "Rocket} {Super Dart}}"; $p->create_field($llx, $lly, $llx + $width, $lly + $height, "plane", "listbox", $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_listbox.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; ?>