Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Draw a rectangle in a PDF document using iText

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

like image 337
Milhous Avatar asked Aug 21 '09 12:08

Milhous


1 Answers

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();
like image 128
Milhous Avatar answered Sep 24 '22 00:09

Milhous



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!