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.Element; import com.lowagie.text.Phrase; import com.lowagie.text.pdf.ColumnText; import com.lowagie.text.pdf.PdfContentByte; import com.lowagie.text.pdf.PdfGState; import com.lowagie.text.pdf.PdfTemplate; import com.lowagie.text.pdf.PdfTransparencyGroup; 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 cb = writer.getDirectContent(); float gap = (document.getPageSize().width() - 400) / 3; pictureCircles(gap, 500, cb); cb.saveState(); PdfGState gs1 = new PdfGState(); gs1.setFillOpacity(0.5f); cb.setGState(gs1); cb.resetRGBColorFill(); ColumnText ct = new ColumnText(cb); Phrase ph = new Phrase("Ungrouped objects\nObject opacity = 1.0"); ct.setSimpleColumn(ph, gap, 0, gap + 200, 500, 18, Element.ALIGN_CENTER); ct.go(); document.close(); } public static void pictureCircles(float x, float y, PdfContentByte cb) { cb.setColorFill(Color.red); cb.circle(x + 70, y + 70, 50); cb.fill(); cb.setColorFill(Color.yellow); cb.circle(x + 100, y + 130, 50); cb.fill(); cb.setColorFill(Color.blue); cb.circle(x + 130, y + 70, 50); cb.fill(); } }