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("Press \"Tab\" to move from one field to the next in " . "the tab order defined.", $llx, $lly, ""); /* 行から行、列から列にタブ順序を定義し、テキストフィールドのマトリクスを * 作成する(taborder=...) * 各テキストフィールドはタブ順序内の位置を示している(currentvalue={...}) */ $optlist = "backgroundcolor={rgb 0.95 1 0.95} bordercolor={gray 0} " . "alignment=center font=" . $font . " fontsize=18"; $lly-= 50; for ($i = 1; $i <= 3; $i++) { for ($j = 1, $tab=$i; $j <= 3; $j++, $tab+=3) { $p->create_field($llx, $lly, $llx + $width, $lly + $height, "field" . $tab, "textfield", $optlist . " taborder=" . $tab . " currentvalue={tab position " . $tab . "}"); $llx+=$width + 20; } $llx = 10; $lly -= $height + 30; } $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_tab_order.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; ?>