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.Paragraph;
import com.lowagie.text.pdf.PdfWriter;
public class MainClass {
public static void main(String[] args) throws Exception {
Document document = new Document(PageSize.A4);
PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
document.open();
BufferedReader reader = new BufferedReader(new FileReader("a.txt"));
String line;
Paragraph p;
while ((line = reader.readLine()) != null) {
p = new Paragraph(" " + line);
p.setAlignment(Element.ALIGN_JUSTIFIED);
document.add(p);
}
reader.close();
document.close();
}
}
|