Remove left and right side borders in itextshap and want a rectanglur box

前端 未结 1 746
没有蜡笔的小新
没有蜡笔的小新 2021-01-26 05:20

Remove the left and right side borders of Approved By and sign and also i need to draw a small rectangular box after calibration certificate no:

PdfPCell Calibr         


        
相关标签:
1条回答
  • 2021-01-26 05:44

    This indeed removes the border:

    CAPAContent.Border = 0;
    

    But whenever I see a student doing this, I'd subtract a point because using an int makes the code hard to read. It's better to do this:

    CAPAContent.Border = Rectangle.NO_BORDER;
    

    This way, you can easily see the 0 means: no border will be drawn.

    Using the constants that are available in the Rectangle class, also teaches you that there are other options. For instance: If you want to tweak the borders as shown in your screen shot, 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 tweaks the borders exactly the way you want to. See also Chapter 4 of "iText in Action - Second Edition", more specifically the example RotationAndColors.cs

    Extra answer:

    You probably refuse to accept this answer because I didn't answer your follow-up question in the comments. However, you didn't answer my question either. You want to add a tick box, but you aren't answering the question: Do you want an interactive one? That is: a check box that is an actual form field (AcroForm technology). Or do you want a check box character? That is: a Zapfdingbats character that represents a small empty square.

    Let's assume that you merely want a character like this:

    That can be easily done with a Zapfdingbats character 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);
    
    0 讨论(0)
提交回复
热议问题