Java tutorial
import java.awt.Color; import java.io.FileOutputStream; import java.io.IOException; import com.lowagie.text.Document; import com.lowagie.text.DocumentException; import com.lowagie.text.pdf.CMYKColor; import com.lowagie.text.pdf.GrayColor; import com.lowagie.text.pdf.PdfContentByte; import com.lowagie.text.pdf.PdfSpotColor; import com.lowagie.text.pdf.PdfWriter; import com.lowagie.text.pdf.SpotColor; public class MainClass { public static void main(String[] args) throws Exception { Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); PdfSpotColor psc_g = new PdfSpotColor("iTextSpotColorGray", 0.5f, new GrayColor(0.9f)); PdfSpotColor psc_rgb = new PdfSpotColor("iTextSpotColorRGB", 0.9f, new Color(0x64, 0x95, 0xed)); PdfSpotColor psc_cmyk = new PdfSpotColor("iTextSpotColorCMYK", 0.25f, new CMYKColor(0.3f, .9f, .3f, .1f)); SpotColor sc_g = new SpotColor(psc_g); SpotColor sc_rgb1 = new SpotColor(psc_rgb, 0.1f); SpotColor sc_cmyk = new SpotColor(psc_cmyk); cb.setColorFill(sc_g); cb.rectangle(36, 770, 36, 36); cb.fillStroke(); cb.setColorFill(psc_g, psc_g.getTint()); cb.rectangle(90, 770, 36, 36); cb.fillStroke(); cb.setColorFill(psc_g, 1); cb.rectangle(252, 770, 36, 36); cb.fillStroke(); cb.setColorFill(sc_rgb1); cb.rectangle(36, 716, 36, 36); cb.fillStroke(); cb.setColorFill(psc_rgb, 0.9f); cb.rectangle(36, 662, 36, 36); cb.fillStroke(); cb.setColorFill(sc_cmyk); cb.rectangle(36, 608, 36, 36); cb.fillStroke(); cb.setColorFill(psc_cmyk, psc_cmyk.getTint()); cb.rectangle(90, 608, 36, 36); cb.fillStroke(); document.close(); } }