begin_document("", "") == 0) { throw new Exception("Error: " . $p->get_errmsg()); } $p->set_option("searchpath={" . $searchpath . "} errorpolicy=return"); $p->set_info("Creator", "PDFlib Cookbook"); $p->set_info("Title", $title); /* Page size may be adjusted by PDF_fit_image() */ $p->begin_page_ext(0, 0, "width=a4.width height=a4.height"); $devicen = $p->create_devicen("names={{PANTONE 123 U} {PANTONE 289 U}} " . "alternate=lab transform={{" . $transformFunc . "}} " . "subtype=nchannel process={colorspace=devicecmyk components={Cyan Magenta Yellow Black}}"); if ($devicen == 0) { throw new Exception("Error: " . $p->get_errmsg()); } /* * Load raw image; we must provide the image parameters in the * option list. The number of color components is deduced from the * DeviceN color handle. */ $optlist = "width=256 height=50 bpc=8 colorize=" . $devicen; $image = $p->load_image("raw", $filename, $optlist); if ($image == 0) { throw new Exception("Error: " . $p->get_errmsg()); } $p->fit_image($image, 0.0, 0.0, "adjustpage"); $p->close_image($image); $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=colorize_image_with_DeviceN_color.pdf"); print $buf; } catch (PDFlibException $e) { echo("PDFlib exception occurred in colorize_image_with_DeviceN_color sample:" . "[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " . $e->get_errmsg()); exit(1); } catch (Throwable $e) { echo($e); exit(1); } $p= 0;