Required jars:

  • itext-1.1.4.jar
  • itext-rups-2.1.3.jar
  • jdtaus-editor-client-application-1.0-beta-10.jar
  • PDFRenderer.jar

package com.liferay;

import java.io.BufferedReader;
import java.io.FileOutputStream;
import java.io.InputStreamReader;

import com.lowagie.text.Document;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;

public class TextToPDF{
public static void main(String arg[]){
try{
InputStreamReader in= new InputStreamReader(System.in);
BufferedReader bin= new BufferedReader(in);
System.out.println("Enter text:");
String text=bin.readLine();
Document document = new Document(PageSize.A4, 36, 72, 108, 180);
PdfWriter.getInstance(document,new FileOutputStream("E:/workspace/rnd/javarnd/pdfFile.pdf"));
document.open();
document.add(new Paragraph(text));
System.out.println("Text is inserted into pdf file");
document.close();
}catch(Exception e){}
}
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: