Java tutorial
import java.io.FileOutputStream; import com.lowagie.text.Document; import com.lowagie.text.pdf.GrayColor; import com.lowagie.text.pdf.PdfContentByte; import com.lowagie.text.pdf.PdfWriter; 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 over = writer.getDirectContent(); PdfContentByte under = writer.getDirectContentUnder(); drawLayer(over, 70, 750, 150, 100); drawLayer(under, 70, 730, 150, 100); document.close(); } public static void drawLayer(PdfContentByte cb, float llx, float lly, float w, float h) { cb.saveState(); cb.setColorFill(new GrayColor(0.9f)); cb.setColorStroke(new GrayColor(0.2f)); cb.moveTo(llx, lly); cb.lineTo(llx + w / 4, lly + h / 3); cb.lineTo(llx + 7 * w / 8, lly + h / 3); cb.lineTo(llx + (2 * w) / 3, lly); cb.closePathFillStroke(); cb.restoreState(); } }