Is there a way to draw a rectangle in PdfPCell in iText (Java version)?

I found some tutorials on how to draw forms in iText, but I need to paste it into a cell, and I don't know how to do it. Thank you for considering this.

+1
source share
3 answers

The iText image extends the rectangle. You can make a new image implementation.

You can create an image from a template, and you can create a template using the content byte.

Thus, you can create a template, draw a rectangle on it, create an image, and then set the image to the desired cell. I did something similar with a rectangle pattern a while ago.

: , setBackground setBorder.

+2

google , , , ( Jes ...) , ll , .

PdfPTable table = new PdfPTable(1);
table.setTotalWidth(450);

PdfTemplate template = cb.createTemplate(30, 30);
template .setLineWidth(0.5f);
template .rectangle(0, 0, 17f, 17f);
template .stroke();

Image img = Image.getInstance(template);        
Chunk chunk = new Chunk(img, 1f, 1f);

PdfPCell cell = new PdfPCell();
cell.addElement(chunk);
table.addCell(cell);
+8

PdfPCellhas a way to set the image PdfPCell#setImage(Image). Could you use it?

0
source

All Articles