interchange/control_nexpress_trays
For NexPress digital color printing machines, create special annotations to control the input tray.
Download Java Code Switch to PHP Code Show Output
/*
* Control NexPress trays:
* Create a special Stamp annotation which is interpreted by
* Kodak NexPress digital color printers to select the input tray.
*
* Use the "custom" option of create_annotation() to create a "Stamp" annotation
* with NexPress-specific custom extensions.
* The "P" in "PDF" means "Portable", which excludes the use of device-specific
* parameters such as tray control. This technique is not really in the spirit
* of portable PDF documents, but NexPress digital printing machines expect it
* this way nevertheless.
*
* The annotation is created outside the page area to ensure that it won't
* be visible on the printed page.
*
* Required software: PDFlib/PDFlib+PDI/PPS 9
* Required data: none
*/
package com.pdflib.cookbook.pdflib.interchange;
import com.pdflib.pdflib;
import com.pdflib.PDFlibException;
public class control_nexpress_trays
{
public static void main (String argv[])
{
/* This is where the data files are. Adjust as necessary. */
String searchpath = "../input";
String outfile = "control_nexpress_trays.pdf";
String title = "Control NexPress trays";
pdflib p = null;
int font, tmpl, path;
int exitcode = 0;
try {
p = new pdflib();
p.set_option("searchpath={" + searchpath + "}");
/* This means we must check return values of load_font() etc. */
p.set_option("errorpolicy=return");
/* Start the document */
if (p.begin_document(outfile, "") == -1)
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("NotoSerif-Regular", "unicode", "");
if (font == -1)
throw new Exception("Error: " + p.get_errmsg());
/* Create a template for visualizing the Stamp annotation */
tmpl = p.begin_template_ext(100, 50, "");
path = p.add_path_point(-1, 50, 25, "rect",
"round=15 width=94 height=44");
p.draw_path(path, 0, 0, "fill fillcolor=lightblue stroke " +
"strokecolor=blue linewidth=3");
p.fit_textline("Cover", 10, 5,
"font=" + font + " fontsize=24 position=center " +
"fitmethod=meet boxsize={80 40} fillcolor=black");
p.end_template_ext(0, 0);
/* 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
* provided by Kodak.
*/
String 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} " +
// Provide a template as visualization of the annotation
"template={normal=" + tmpl + "}";
p.create_annotation(620, 450, 720, 500, "Stamp", optlist);
p.end_page_ext("");
p.end_document("");
} catch (PDFlibException e) {
System.err.println("PDFlib exception occurred:");
System.err.println("[" + e.get_errnum() + "] " + e.get_apiname()
+ ": " + e.get_errmsg());
exitcode = 1;
} catch (Exception e) {
System.err.println(e);
exitcode = 1;
} finally {
if (p != null) {
p.delete();
}
System.exit(exitcode);
}
}
}