Convert Text File to PDF file

Convert Text File to PDF file

import java.io.BufferedReader; import java.io.FileOutputStream; import java.io.FileReader;

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

public class TextFileToPDF { private static void doReadWriteTextFile() {

    try {

        BufferedReader inputStream = new BufferedReader(new FileReader(
                Input File));

        String inLine = null;
        StringBuffer sb = new StringBuffer("");

        while ((inLine = inputStream.readLine()) != null) {

            sb.append(inLine);
        }

        Document document = new Document();
        PdfWriter.getInstance(document, new FileOutputStream(
                output file));
        document.open();
        document.add(new Paragraph(sb.toString()));
        sb.append(inLine);
        System.out.println("Text is inserted into pdf file");
        document.close();

        inputStream.close();

    } catch (Exception e) {

        System.out.println("IOException:");
        e.printStackTrace();

    }

}

public static void main(String[] args) {
    doReadWriteTextFile();
}

}

View Answers









Related Tutorials/Questions & Answers:
Convert Text File to PDF file
Convert Text File to PDF file  Here is the way how to covert your Text file to PDF File, public class TextFileToPDF { private static void...(inLine); System.out.println("Text is inserted into pdf file
Convert Text File to PDF file
Convert Text File to PDF file  import java.io.BufferedReader; import...); System.out.println("Text is inserted into pdf file"); document.close... FileReader( Input File)); String inLine = null
Advertisements
convert data from pdf to text file - Java Beginners
convert data from pdf to text file   how to read the data from pdf file and put it into text file(.txt
Convert pdf to text file using Java
How to Convert pdf to text file in Java In this section, you will learn how to convert pdf file to text file in Java Programming. We have used itext api for this purpose. To read resume.pdf  file, we have used PDFReader class
Java code to convert pdf file to word file
Java code to convert pdf file to word file  How to convert pdf file to word file using Java
convert an pdf file to html in Java
convert an pdf file to html in Java  Hi all, How to convert an pdf file to html in Java? Currently all my data is generated into a report in pdf and i want to be able to generate it to html page as well. How to go about
CONVERT JTable DATA TO PDF FILE
CONVERT JTable DATA TO PDF FILE  HOW TO CONVERT JTable DATA TO .PDF FILE??PLEASE GIVE ME CODE FOR THAT.   Here is an example that reads the jtable data from the jframe and stored the data into the pdf file in the form
how to convert image file to text file?
how to convert image file to text file?  hi, can anybody tell how to convert image file to text file? plz help me
How to Convert PDF into rtf File Java
How to Convert PDF into rtf File Java  Hi, How could in covert the PDF file to rtf file in Java Programming. Please suggest any online example... the online example of Java Convert PDF into rtf File. Thanks
Add text into the pdf File - Development process
Add text into the pdf File  Hi friend, How can i insert or Add text into the pdf file from the exsting one in java.. Thanks in Advance...  Hi Friend, Please visit the following links: http
How to Convert Text Files into Gzip File
How to Convert Text Files into Gzip File  Hi, I am developing a small application using PHP language. The real problem is that how do i convert the text files into gzip file. how can i solve the problem.... Tnanks
Java convert jtable data to pdf file
Java convert jtable data to pdf file In this tutorial, you will learn how to convert jtable data to pdf file. Here is an example where we have created... have fetched the data from the jtable and save the data to pdf file. Example
how to convert text file to xml file in java. - XML
how to convert text file to xml file in java.  Hi all, I m having some problem. Problem is I want to convert a text file which is having the no of record(i.e no of different line of information)to a xml file through java
Convert text file to XML file in Java
Convert text file to XML file Java In this section, you will learn how to convert the text file into xml file in Java language. To do this, we have used... file. The Parser invoked startElement() method at the beginning of every element
Convert pdf to rtf file using Java
Convert pdf to rtf file using Java In this section, you will learn how to convert .pdf file to .rtf file in java programming language. We have used itext api for this purpose. To read resume.pdf  file, we have used PDFReader class
Convert Text To PDF
Convert Text To PDF       Here we are discussing the convertion of a text file into a pdf file... required for the conversion of a text file into the pdf file from http
Download PDF file
Download PDF file  How to download PDF file with JSF
pdf file in jsp
pdf file in jsp  i have a pdf, which has to be displayed in a jsp page along with some html tags, the pdf which is to be displayed shold be readonly and wont allow the uer to save too
about pdf file handeling
about pdf file handeling  can i apend something in pdf file using... to handle pdf files. You can find the related examples from the given link: Handling PDF files
text file
text file  Hello can I modify the program below so that all the numerical data is stored in an external text file,that is the data contained in the array list.Thank you! mport java.util.*; import java.text.*; import
text file
text file  Hi can you help me I have to modify the program below so that all the data held in it is stored in an external text file.So there should... at the start of the program from a seperate external text file.Thank you! mport
about pdf file handeling
about pdf file handeling  i have downloaded a jar file containing packages for writing in pdf files . in which folder i should copy it ? i'm using windowsXP os.pls give whole path
upload the pdf file only - Struts
upload the pdf file only  plz tell me,in my web application i want to upload only pdf file.but i m getting the problem when anyone change the extesion of EXE or TEXT with .pdf its also upload.plz give me response ASAP plz
read restricted pdf file
read restricted pdf file  i have restricted file. package Encryption; import java.io.*; import java.util.*; import com.lowagie.text...."+e.getStackTrace()); } } } pdf given to code
read restricted pdf file
read restricted pdf file  i have restricted file. package Encryption; import java.io.*; import java.util.*; import com.lowagie.text.*; import...()); } } } pdf given to code is in marathi it gives following output
Uploading and download pdf or .txt file.
Uploading and download pdf or .txt file.  I want admin user to upload pdf file into database and the users can download those pdf format from database
converting html file into pdf - Struts
converting html file into pdf  i want to convert html file into pdf file using java code please help me
how to dispaly pdf file on browser
how to dispaly pdf file on browser  In my project i have created one pdf file(by pdfwriter) into my local mechine . after that it need to display in browser as a pdf file . but in jsp i can't display by tag can anyone give me
Converting the text files into gzip file.
Converting text file into gzip file This example will explain you how to convert text files into gzip file. Under gzip operation, first text files... text file into gzip and write gzip and read gzip file operation $filecompress
Generate pdf file - JSP-Servlet
Generate pdf file   Hi Friends, How to generate the pdf file for the jsp page or in servets  Hi Friend, You need to download itext api. After that set the classpath and try the following code
how to display pdf file on browser
how to display pdf file on browser   In my project i have created one pdf file(by pdfwriter) into my local mechine . after that it need to display in browser as a pdf file . but in jsp i can't display by iframe tag can anyone
convert a file .doc to .zip
convert a file .doc to .zip  hiii, I uploaded a file...;TITLE>Display file upload form to the user</TITLE></HEAD> <...;td><b>Choose the file To Upload:</b></td> <td><
Reading a text file in java
Reading a text file in java  What is the code for Reading a text file... in java.io.* package for reading and writing to a file in Java. To learn more about reading text file in Java see the tutorial Read File in Java. Thanks
how to generate pdf file in struts
how to generate pdf file in struts  I am developing a struts application.I am having one registration form when i am submitting the form the values... be shown as pdf or excel format
how to generate pdf file in struts
how to generate pdf file in struts  I am developing a struts application.I am having one registration form when i am submitting the form the values... be shown as pdf or excel format
how to convert a text file thats is in russian to english and vice versa using java ?
how to convert a text file thats is in russian to english and vice versa using java ?   Hello, I am a beginner to java, I want to convert a text file which is in english to russian and vice versa Kindly advice me Thanks
Read PDF file
Read PDF file Java provides itext api to perform read and write operations with pdf file. Here we are going to read a pdf file. For this, we have used PDFReader class. The data is first converted into bytes and then with the use
Sorting text file
Sorting text file  Hello friends, i'm writing search page for my local website. i'm storing all file list in text file. And also adding a value... according to begin value. Text File having list like this: 5| 3| can anyone
upload only pdf file - Struts
upload only pdf file  in web application,i want to attach only pdf file but if i change the extension of EXE or TXT files with PDF Extension its also upload ,but i want to upload only pdf file not only the extesion but also
how to update the text file?
how to update the text file?  if my text file contains a string and integer in each line say,: aaa 200 bbb 500 ccc 400 i need a java code to update the integer value if my input String matches with the string in file. please
uploading a text file into a database
uploading a text file into a database  how to upload a text file... { static File file; public static void main(String[] args) throws Exception { JLabel label=new JLabel("Choose File
Write Hello in the pdf file
Write Hello in the pdf file     ...;Hello" word in a pdf file irrespective of the fact whether it exists...*, and com.lowagie.text.*. These two package will help us to make and use pdf file in our program.ADS
pdf to text
pdf to text  how to covert pdf file (which contain table and text) into word or excel file using itext api
how to update the text file?
how to update the text file?  my textfile with name list.txt: Rice... i want to update the quantity in my text file, if the item i entered matches...=new float[n1]; for(int i=0;i File file ; FileReader fr=null
form field mapping with pdf file using java
form field mapping with pdf file using java   Hai all, I have one... file. means, if click on text field according that perticular field .the data related to the field in pdf file should marked with a color. can any one give
Read text File
Read text File  Hi,How can I get line and keep in a String in Java
how to convert .xml file to csv file
how to convert .xml file to csv file  how to convert .xml file to csv file
how to convert a jar file into .exe file
how to convert a jar file into .exe file  hi, I want convert my jar file into executable file,urgently please help me
To send pdf file to email in java
To send pdf file to email in java   Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: com/sun/mail/util/MailLogger at javax.mail.Session.initLogger(Session.java:283) at javax.mail.Session.
Convert Class File to .java File - Java Beginners
Convert Class File to .java File  Sir, How To Convert .class file to .java File. Please Help me  Use cavaj software ,which is freeware, to convert .class to .java  Use jd-gui to convert ur .class to .java

Ads