Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I just started using this library. How can i position text in a cell at middle and at bottom?

PdfFont font = PdfFontFactory.createFont(StandardFonts.HELVETICA_BOLD);
Paragraph para = new Paragraph("Test").setFont(font);

Table table = new Table(UnitValue.createPercentArray(1)).useAllAvailableWidth();
Cell cell = new Cell();
cell.setMinHeight(100);
cell.setVerticalAlignment(VerticalAlignment.MIDDLE);
cell.add(para);
cell.add(new Paragraph("test")).setVerticalAlignment(VerticalAlignment.BOTTOM);
table.addCell(cell);

Currently setting the vertical alignment the content is aligned to the bottom. The output:
The output

How can I achieve the position of text at middle and bottom? Like this with in the same cell:

output

Thanks.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
234 views
Welcome To Ask or Share your Answers For Others

1 Answer

    PdfFont font = PdfFontFactory.createFont(StandardFonts.HELVETICA_BOLD);
    Paragraph para = new Paragraph("Test").setFont(font);

    Table table = new 
    Table(UnitValue.createPercentArray(1)).useAllAvailableWidth();
table.setHorizontalAlignment(HorizontalAlignment.CENTER);
    table.setTextAlignment(TextAlignment.CENTER);

    Cell cell = new Cell();
    cell.setMinHeight(100);
    cell.setVerticalAlignment(VerticalAlignment.MIDDLE);
    cell.add(para);
    cell.add(new Paragraph("test")).setVerticalAlignment(VerticalAlignment.BOTTOM);
    table.addCell(cell);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...