7

I have 2 lines and I want to align (justify) them.

I have this code:

    Paragraph p=new Paragraph(ANC,fontFootData);
    p.setLeading(1, 1);
    p.setAlignment(Element.ALIGN_JUSTIFIED);
    document.add(p);


    Paragraph p2=new Paragraph(RUTTEL,fontFootData);
    p2.setLeading(1, 1);
    p2.setAlignment(Element.ALIGN_JUSTIFIED);
    document.add(p2);

where ANC and RUTTEL are string, but they not be align.

Could anybody help me?

Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165
danivare
  • 91
  • 1
  • 1
  • 3
  • 1
    How long are those strings? Maybe you're looking for ALIGN_JUSTIFIED_ALL instead of ALIGN_JUSTIFIED. In any case: alignment works for us, there's no reason it shouldn't work for you. – Bruno Lowagie Jun 27 '13 at 11:13

2 Answers2

4

For a one line use ALIGN_JUSTIFIED_ALL, more than one line use ALIGN_JUSTIFIED.

Osman Yilmaz
  • 63
  • 1
  • 7
  • 2
    just want to add api reference here http://itextsupport.com/apidocs/itext5/latest/ ALIGN_JUSTIFIED_ALL Does the same as ALIGN_JUSTIFIED but the last line is also spread out. –  Nov 11 '16 at 04:45
0

If you are using for C#, then:

p.Alignment = Element.ALIGN_JUSTIFIED;
סטנלי גרונן
  • 2,917
  • 23
  • 46
  • 68
Abi Chhetri
  • 1,131
  • 10
  • 15