Draw a rectangle in a PDF document using iText

itext, java, pdf, pdf-generation

Solution

Here is the solution. Thanks Dylan McClung.

PdfWriter writer = ...;
PdfContentByte cb = writer.getDirectContent();
cb.saveState();
cb.setColorStroke(Color.black);
cb.rectangle(x,y,x1,y1);
cb.stroke();
cb.restoreState();

Problem

Is there a way in iText to draw a rectangle in a PDF document?

Original source