Element.ALIGN_JUSTIFIED : Paragraph « PDF « Java Tutorial






import java.io.FileOutputStream;

import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.Element;
import com.lowagie.text.Font;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Phrase;
import com.lowagie.text.pdf.PdfWriter;

public class MainClass {
  public static void main(String[] args) throws Exception {
    Document document = new Document();
    PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
    document.open();
    Chunk space = new Chunk("asdf");
    Paragraph paragraph = new Paragraph();
    paragraph.add(space);
    paragraph.setAlignment(Element.ALIGN_JUSTIFIED);
    document.add(paragraph);
    
    
    document.close();
  }
}








29.20.Paragraph
29.20.1.Add a Paragraph to a document
29.20.2.Paragraph Alignment: ALIGN_JUSTIFIED
29.20.3.Paragraph Alignment: Element.ALIGN_RIGHT
29.20.4.Element.ALIGN_JUSTIFIED
29.20.5.Paragraph Spacing Before
29.20.6.Paragraph Indentation Left
29.20.7.Paragraph Indentation Right
29.20.8.Paragraph Spacing After
29.20.9.Paragraph text
29.20.10.Paragraph Positions
29.20.11.Colored Paragraphs