Create Column With SimpleColumn : Column « PDF « Java Tutorial

Home
Java Tutorial
1.Language
2.Data Type
3.Operators
4.Statement Control
5.Class Definition
6.Development
7.Reflection
8.Regular Expressions
9.Collections
10.Thread
11.File
12.Generics
13.I18N
14.Swing
15.Swing Event
16.2D Graphics
17.SWT
18.SWT 2D Graphics
19.Network
20.Database
21.Hibernate
22.JPA
23.JSP
24.JSTL
25.Servlet
26.Web Services SOA
27.EJB3
28.Spring
29.PDF
30.Email
31.J2ME
32.J2EE Application
33.XML
34.Design Pattern
35.Log
36.Security
37.Apache Common
38.Ant
39.JUnit
Java Tutorial » PDF » Column 
29.24.2.Create Column With SimpleColumnPrevious/Next
import java.io.BufferedReader;
import java.io.FileOutputStream;
import java.io.FileReader;

import com.lowagie.text.Document;
import com.lowagie.text.Element;
import com.lowagie.text.PageSize;
import com.lowagie.text.Phrase;
import com.lowagie.text.pdf.ColumnText;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfWriter;

public class MainClass {
  public static void main(String[] argsthrows Exception {
    Document document = new Document(PageSize.A4);
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
    document.open();
    PdfContentByte cb = writer.getDirectContent();
    StringBuffer sb = new StringBuffer(1024);
    BufferedReader reader = new BufferedReader(new FileReader("a.txt"));
    int c;
    while ((c = reader.read()) > -1) {
      sb.append((charc);
    }
    reader.close();
    ColumnText ct = new ColumnText(cb);
    ct.setSimpleColumn(new Phrase(sb.toString())3636, PageSize.A4.width() 36, PageSize.A4
        .height() 3618, Element.ALIGN_JUSTIFIED);
    int status = ColumnText.START_COLUMN;
    while (ColumnText.hasMoreText(status)) {
      status = ct.go();
      ct.setYLine(PageSize.A4.height() 36);
      document.newPage();
    }
    document.close();
  }
}
29.24.Column
29.24.1.Using ColumnText
29.24.2.Create Column With SimpleColumn
29.24.3.ColumnText.NO_MORE_COLUMN
29.24.4.Column Properties
29.24.5.ColumnText.hasMoreText
29.24.6.Set Column text
29.24.7.Regular Columns
29.24.8.Add SimpleColumn to MultiColumnText
29.24.9.Columns Right To Left
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.