/* * Color space for crop marks: * Create crop marks which will be visible on all color separations, using the * special color "All". * * Create a CMYK document by loading a CMYK image and create the special * color "All". Draw some crop marks with standard vector graphics and * output some info text outside of the actual page area (i.e. outside * of the CropBox). * * Test in Acrobat X/XI: * Show the MediaBox with Tools, Print Production, More Production, * Set Page Boxes, Set to Zero. * Choose Tools, Print Production, Output Preview: * All elements with color "All" will be visible in all combinations of * separation previews. * * Required software: PDFlib/PDFlib+PDI/PPS 9 * Required data: CMYK image */ package com.pdflib.cookbook.pdflib.color; import com.pdflib.pdflib; import com.pdflib.PDFlibException; public class colorAll_for_cropmarks { public static void main(String argv[]) { /* This is where the data files are. Adjust as necessary. */ String searchpath = "../input"; String outfile = "colorAll_for_cropmarks.pdf"; String title = "Color All for Crop Marks"; pdflib p = null; int font, image; String imagefile = "lionel.jpg"; String info = "Lionel watching the big blue lion Page 1 Wednesday, " + "August 01, 2007 8:52 PM"; int pagewidth = 842, pageheight = 595; 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"); if (p.begin_document(outfile, "") == -1) throw new Exception("Error: " + p.get_errmsg()); p.set_info("Creator", "PDFlib Cookbook"); p.set_info("Title", title); /* * Start the page with a crop box defined with 40 units less than * the page size in all directions for placing crop marks and text * info */ p.begin_page_ext(pagewidth, pageheight, "cropbox={40 40 802 555}"); /* Load and fit a CMYK image */ image = p.load_image("auto", imagefile, "honorclippingpath=false"); if (image == -1) throw new Exception("Error: " + p.get_errmsg()); p.fit_image(image, 0, 0, "boxsize={" + pagewidth + " " + pageheight + "} position=center"); /* * The special color "All" will be used for crop marks and info * text; these will be visible on all color separations. */ p.set_graphics_option("fillcolor={spotname All 1} strokecolor={spotname All 1}"); /* Draw crop marks within the CropBox */ /* Draw crop marks at the bottom left */ p.moveto(0, 20); p.lineto(15, 20); p.moveto(20, 0); p.lineto(20, 15); /* Draw crop marks on the top left */ p.moveto(0, pageheight - 20); p.lineto(15, pageheight - 20); p.moveto(20, pageheight); p.lineto(20, pageheight - 15); p.stroke(); /* Draw crop marks on the top right */ p.moveto(pagewidth - 20, pageheight); p.lineto(pagewidth - 20, pageheight - 15); p.moveto(pagewidth, pageheight - 20); p.lineto(pagewidth - 15, pageheight - 20); /* Draw crop marks at the bottom right */ p.moveto(pagewidth - 20, 0); p.lineto(pagewidth - 20, 15); p.moveto(pagewidth, 20); p.lineto(pagewidth - 15, 20); p.stroke(); /* Load the font */ font = p.load_font("Helvetica", "unicode", ""); if (font == -1) throw new Exception("Error: " + p.get_errmsg()); /* Output some info text outside of the CropBox */ p.fit_textline(info, 30, 8, "font=" + font + " fontsize=10"); 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); } } }