set_option("searchpath={" . $searchpath . "}"); /* This means we must check return values of load_font() etc. */ $p->set_option("errorpolicy=return"); $p->set_option("stringformat=utf8"); /* Start the document */ if ($p->begin_document($outfile, "") == 0) throw new Exception("Error: " . $p->get_errmsg()); /* Set document info entries */ $p->set_info("Creator", "PDFlib Cookbook"); $p->set_info("Title", $title ); /* Load font */ $font = $p->load_font("Helvetica", "unicode", ""); if ($font == 0) throw new Exception("Error: " . $p->get_errmsg()); /* Start page */ $p->begin_page_ext(0, 0, "width=a4.width height=a4.height"); /* Set font */ $p->setfont($font, 12); /* Output some descriptive text */ $p->fit_textline("Use the \"custom\" option of create_annotation() to " . "create a \"Stamp\" annotation with", 20, 600, ""); $p->fit_textline("NexPress-specific custom extensions in the document.", 20, 580, ""); /* Create a "Stamp" annotation with NexPress-specific custom * extensions. * Some names which can be used in the "Name" key for tray selection: * SubstrateTypeCover, SubstrateTypeInsert, * SubstrateTypeInsert1 ... SubstrateTypeInsert9. * More details are available in the printer-specific documentation. */ $optlist = "custom={{key=Open type=boolean value=false} " . "{key=Name type=name value=SubstrateTypeCover} " . "{key=Subj type=string value={Cover}}} " . "contents={Stamp Annotation for tray selection}"; $p->create_annotation(50, 500, 150, 550, "Stamp", $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=control_nexpress_trays.pdf"); print $buf; } catch (PDFlibException $e) { die("PDFlib exception occurred in control_nexpress_trays sample:\n" . "[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " . $e->get_errmsg() . "\n"); } catch (Exception $e) { die($e->getMessage()); } $p = 0; ?>