set_option("searchpath={" . $searchpath . "}"); /* This means we must check return values of load_font() etc. */ $p->set_option("errorpolicy=return"); if ($p->begin_document($outfile, "") == 0) throw new Exception("Error: " . $p->get_errmsg()); $p->set_info("Creator", "PDFlib Cookbook"); $p->set_info("Title", $title); /* Start the page */ $p->begin_page_ext(0, 0, "width=a4.height height=a4.width"); /* Draw a background rectangle and fill it with 100% "PANTONE 463 C". */ $p->set_graphics_option("fillcolor={spotname {PANTONE 463 C} 1}"); $p->rect(0, 0, 842, 595); $p->fill(); /* Draw text with the same spot color, but a tint value of 0. Nothing * will be painted because no ink is applied. Due to the colorized * background area the text will be visible nevertheless. */ $p->fit_textline("Reverse Printing", 50, 50, "fontname=NotoSerif-Bold fontsize=40 boxsize={742 495} fitmethod=meet " . "position=center fillcolor={spotname {PANTONE 463 C} 0}"); $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=reverse_printing.pdf"); print $buf; } catch (PDFlibException $e) { echo ("PDFlib exception occurred:\n" . "[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " . $e->get_errmsg() . "\n"); exit(1); } catch (Throwable $e) { echo ("PHP exception occurred: " . $e->getMessage() . "\n"); exit(1); } $p = 0; ?>