Remove the left and right borders in itextshap and want a rectangle

enter image description here Remove the left and right side borders of the approved and signature, and also I need to draw a small rectangular box after the calibration is confirmed:

PdfPCell CalibrationContent = new PdfPCell(FormatPhrase("", 8, Font.NORMAL, BaseColor.BLACK)); CalibrationContent.Colspan = 1; CalibrationContent.BackgroundColor = BaseColor.WHITE; CalibrationContent.NoWrap = true; CalibrationContent.HorizontalAlignment = Element.ALIGN_CENTER; PdfMastertable.AddCell(CalibrationContent); CalibrationContent = new PdfPCell(FormatPhrase("Approved By", 8, Font.NORMAL, BaseColor.BLACK)); CalibrationContent.Colspan = 1; CalibrationContent.MinimumHeight = 20f; CalibrationContent.BackgroundColor = BaseColor.WHITE; CalibrationContent.NoWrap = true; CalibrationContent.HorizontalAlignment =0; pdfMastertable.AddCell(CalibrationContent); CalibrationContent = new PdfPCell(FormatPhrase("Sign", 8, Font.NORMAL, BaseColor.BLACK)); CalibrationContent.Colspan =1; CalibrationContent.MinimumHeight = 20f; CalibrationContent.BackgroundColor = BaseColor.WHITE; CalibrationContent.NoWrap = true; CalibrationContent.HorizontalAlignment = 0; pdfMastertable.AddCell(CalibrationContent); 

Below is the code for this certificate number with the "Box" field

 CAPAContent = new PdfPCell(FormatPhrase("Calibration Certificate No: " + "ddmmyy" + '\n' + "Date Issued : " + "ddmmyy" + '\n' + '\n' + "Monthly instrument type wise " + '\n' + "Test conducted Day wise" + '\n', 11, Font.NORMAL, BaseColor.BLACK)); CAPAContent.Colspan = 1; CAPAContent.BackgroundColor = BaseColor.WHITE; CAPAContent.NoWrap = true; CAPAContent.Border = 0; CAPAContent.HorizontalAlignment = Element.ALIGN_RIGHT; pdfAction.AddCell(CAPAContent); pdfAction.SpacingAfter = 20f; pdfDoc.Add(pdfAction); 
0
source share
1 answer

This really removes the border:

 CAPAContent.Border = 0; 

But whenever I see a student doing this, I would subtract the point, because using int makes the code difficult to read. This is best done:

 CAPAContent.Border = Rectangle.NO_BORDER; 

Thus, you can easily see that a value of 0 means: no border will be drawn.

Using the constants available in the Rectangle class also teaches you that there are other options. For example: if you want to adjust the borders as shown in the screenshot, you can do this:

 PdfPCell CalibrationContent = new PdfPCell(FormatPhrase("", 8, Font.NORMAL, BaseColor.BLACK)); CalibrationContent.Border = Rectangle.TOP | Rectangle.LEFT | Rectangle.BOTTOM; ... CalibrationContent = new PdfPCell(FormatPhrase("Approved By", 8, Font.NORMAL, BaseColor.BLACK)); CalibrationContent.Border = Rectangle.TOP | Rectangle.BOTTOM; ... CalibrationContent = new PdfPCell(FormatPhrase("Sign", 8, Font.NORMAL, BaseColor.BLACK)); CalibrationContent.Border = Rectangle.TOP | Rectangle.RIGHT | Rectangle.BOTTOM; 

This adjusts the borders exactly the way you want. See also Chapter 4, β€œiText in Action - Second Edition,” a more specific example of RotationAndColors.cs

Additional answer:

You probably refuse to accept this answer because I did not answer your subsequent question in the comments. However, you did not answer my question either. You want to add a checkmark, but you do not answer the question: do you need interactive? That is: a flag, which is the actual form field (AcroForm technology). Or do you need a flag symbol? That is: the Zapfdingbats symbol representing a small empty square.

Suppose you just want a character like this:

enter image description here

This is easy to do with the Zapfdingbats symbol, as shown in the TickboxCharacter example:

 Paragraph p = new Paragraph("This is a tick box character: "); Font zapfdingbats = new Font(Font.FontFamily.ZAPFDINGBATS, 14); Chunk chunk = new Chunk("o", zapfdingbats); p.add(chunk); document.add(p); 
+2
source share

All Articles