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

Ads









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
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
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
Download PDF file
Download PDF file  How to download PDF file with JSF
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
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
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  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
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
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
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
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
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
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
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
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. Now
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
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
Read text File
Read text File  Hi,How can I get line and keep in a String in Java
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
pdf to text
pdf to text  how to covert pdf file (which contain table and text) into word or excel file using itext api
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.
pdf file measurement
pdf file measurement      ... on a pdf file,. To make the program for changing the pdf version firstly we have... of text, tells the PDF document writer to ensure that the Paragraph's text
inserting text into text file using java application
inserting text into text file using java application  Hi, I want to insert a text or string into a text file using java application
Converting Text Files into Bzip File
Converting Text Files into Bzip File  Hi, I am facing the problem during run the program, when converting text files into Bzip file. Please guide me how do i convert the text file into bzip file in PHP. I will welcome, if anyone
How to convert XML file to database ?
How to convert XML file to database ?  How to convert XML file to database
convert zip file to byte array
convert zip file to byte array  Hi,How to convert zip file to byte array,can you please provide program?? Thanks, Ramanuja
how can i display a pdf file in a jtextarea
how can i display a pdf file in a jtextarea  I need to display a pdf file in a jtextfield or in a jtextarea.Atlest i need to displat it in a jframe.I have a button and while clicking on it ,i need to choose the pdf file and need
How to adjust a size of a pdf file
How to adjust a size of a pdf file   ... adjust the size of a pdf file irrespective of the fact whether it exists or not. If it exists then its fine, otherwise a pdf file will be created. 
Java convert file to byte array
Java convert file to byte array  How to convert file to byte array in Java? Thanks   Hi, To convert file to byte array in Java you have.... Read the complete examples at: Reading file into bytearrayoutputstream Reading
how to create pdf file using java and itextjar
how to create pdf file using java and itextjar  How to create pdf file having paragraphs and alignments done using java and itextjar 5.10 version.? hope i get quick response
how to create pdf file using java and itextjar
how to create pdf file using java and itextjar  How to create pdf file having paragraphs and alignments done using java and itextjar 5.10 version.? hope i get quick response
writing a text into text file at particular line number
writing a text into text file at particular line number   Hi, thanks for quick response, I want to insert text at some particular line number.. after line number four my text will display in text file using java program
Convert InputStream to File
Convert InputStream to File       Here we are showing how to convert an InputStream... to retrieve the file from system for modification then convert the InputSteam
Text field save as word file
Text field save as word file  Dear experts At run how to save set of text field contains text into single Word file. To save in our desktop computer. Solve my problem
Print pdf file in JavaScript - IE and Chrome
Print pdf file in JavaScript - IE and Chrome  <!DOCTYPE html>...;!--Print pdf file in JavaScript - IE and Chrome (if not working in chrome add this html in war file of your server <script type="text/javascript">
Convert Text To Word
Convert Text To Word       In this example, You will learn how to convert text to word file. Here, we are going to discuss about the conversion of text to word file.  Core
PDF Copy(File) has many pages.
PDF Copy(File) has many pages.  Dear All, I make Jasper Report it compile ,run and view properly. when i am try to send it pdf format it also sent it it pdf properly. but a that PDF Copy(File) has many pages. single copy
How to wrap image in the pdf file
How to wrap image in the pdf file   ... insert a image  and wrap it according to your own style in a pdf file...*, and com.lowagie.text.*. These two package will help us to make and use pdf file in our

Ads