Convert pdf to rtf and txt

Convert pdf to rtf and txt

View Answers

October 9, 2009 at 3:33 PM

Hi Friend,

Try the following codes:

1)Convert PDF to RTF
import java.io.*;
import java.util.*;
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;

public class ConvertPDFToRTF {
public static void main(String[] args) throws IOException {
try {
Document document = new Document();
document.open();
PdfReader reader = new PdfReader("C:\\resume.pdf");
PdfDictionary dictionary = reader.getPageN(1);
PRIndirectReference reference = (PRIndirectReference) dictionary.get(PdfName.CONTENTS);
PRStream stream = (PRStream) PdfReader.getPdfObject(reference);
byte[] bytes = PdfReader.getStreamBytes(stream);
PRTokeniser tokenizer = new PRTokeniser(bytes);
FileOutputStream fos=new FileOutputStream("resume.rtf");
StringBuffer buffer = new StringBuffer();
while (tokenizer.nextToken()) {
if (tokenizer.getTokenType() == PRTokeniser.TK_STRING) {
buffer.append(tokenizer.getStringValue());
}
}
String test=buffer.toString();
StringReader stReader = new StringReader(test);
int t;
while((t=stReader.read())>0)
fos.write(t);
document.close();
System.out.println("Converted Successfully");
}
catch (Exception e) {}
}
}

2)Convert PDF to TEXT
import java.io.*;
import java.util.*;
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;

public class ConvertPDFToTEXT {
public static void main(String[] args) throws IOException {
try {
Document document = new Document();
document.open();
PdfReader reader = new PdfReader("C:\\resume.pdf");
PdfDictionary dictionary = reader.getPageN(1);
PRIndirectReference reference = (PRIndirectReference) dictionary.get(PdfName.CONTENTS);
PRStream stream = (PRStream) PdfReader.getPdfObject(reference);
byte[] bytes = PdfReader.getStreamBytes(stream);
PRTokeniser tokenizer = new PRTokeniser(bytes);
FileOutputStream fos=new FileOutputStream("pdf.txt");
StringBuffer buffer = new StringBuffer();
while (tokenizer.nextToken()) {
if (tokenizer.getTokenType() == PRTokeniser.TK_STRING) {
buffer.append(tokenizer.getStringValue());
}
}
String test=buffer.toString();
StringReader stReader = new StringReader(test);
int t;
while((t=stReader.read())>0)
fos.write(t);
document.add(new Paragraph(".."));
document.close();
}
catch (Exception e) {}
}
}
Thanks









Related Tutorials/Questions & Answers:
Convert pdf to rtf and txt - XML
Convert pdf to rtf and txt  Can we convert PDF to RTF and TXT, and how?  Hi Friend, Try the following codes: 1)Convert PDF to RTF...) {} } } 2)Convert PDF to TEXT import java.io.*; import java.util.
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
Advertisements
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
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 excel into pdf
convert excel into pdf  How to convert excel into pdf files
convert word document to pdf
convert word document to pdf  Hi, Could you please help me write a java code that converts the word docuemnt into PDF? I have to save the generated..."); f.convert(fos,"pdf"); I would also want to know, what does "OfficeFile" in the code
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 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 .txt file in .csv format - Java Beginners
convert .txt file in .csv format  Dear all, I hope you are doing good. I am looking to convert .txt file in .csv format. The contents might have different names and values. e.g. start: id:XXXX name:abc address:xyz
rtf
created one JSP(used pre defined javascript in jsp to get rtf format in browser) which creats RTF Format in browser to enter data. MY question is after i...); //convert all types of single quotes /*tmpString = tmpString.replace((char
Convert BLOB to PDF and save it to a location
Convert BLOB to PDF and save it to a location  I have a requirement to convert blob(stored in a DB table) back to .pdf in the UI(for the users... it has to convert each blob to a pdf and zip it, which the user should be able
'Hello World' file from a servlet (PDF, HTML or RTF).
 'Hello World' file from a servlet (PDF, HTML or RTF...; In this program we are going to tell you how we can create three file rtf,pdf and html files.And we are printing here Hello Word on PDF, HTML, And RTF formate
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
How to convert a swing form to PDF
How to convert a swing form to PDF  Sir, I want to know about how convert a swing form containing textbox,JTable,JPanel,JLabel, Seperator etc swing menus to a PDF file using java code
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...); System.out.println("Text is inserted into pdf file"); document.close
CONVERT JTable DATA TO PDF FILE
CONVERT JTable DATA TO PDF FILE  HOW TO CONVERT JTable DATA TO .PDF... the jtable data from the jframe and stored the data into the pdf file in the form...); button=new JButton("Save to pdf"); button.addActionListener(new ActionListener
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
to convert html to pdf in java - Java Beginners
to convert html to pdf in java  HI all, i want to convert html to pdf using java. actually i dont need as the tags in the html. but the tags should be removed and i need only the text in that. Thanks in advance
To convert Html to pdf in java - Java Beginners
To convert Html to pdf in java  Hi all, I want to convert html file to pdf file using java. can any one help me out. Thanks & Regards Santhosh Ejanthkar  Hi Friend, Try the following code: import
Convert PDF to XML in Java
Convert PDF to XML File in Java In this Java tutorial section, you will learn how to convert pdf file to xml using java program. We have used itext api for this purpose. To read hello.pdf file, we have used PDFReader class. The data
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
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
Convert ZIP To PDF
Convert ZIP To PDF       Lets discuss the conversion of a zipped file into pdf file..., unzip it and then store it into a byte array. Convert this array of byte
Convert Text To PDF
Convert Text To PDF       Here we are discussing the convertion of a text file into a pdf file... into the add() method of the document class to generate a pdf file. Download iText API
ModuleNotFoundError: No module named 'rtf'
ModuleNotFoundError: No module named 'rtf'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'rtf' How to remove the ModuleNotFoundError: No module named 'rtf' error
rtf_jsp_javascript
rtf_jsp_javascript  Hi every one plz give me answer for below question ASAP I created one JSP(used pre defined javascript in jsp to get rtf format in browser) which creats RTF Format in browser to enter data. MY question
Version of com.lowagie>itext-rtf dependency
List of Version of com.lowagie>itext-rtf dependency
ModuleNotFoundError: No module named 'compressed-rtf'
ModuleNotFoundError: No module named 'compressed-rtf'  Hi, My... named 'compressed-rtf' How to remove the ModuleNotFoundError: No module named 'compressed-rtf' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'compressed-rtf'
ModuleNotFoundError: No module named 'compressed-rtf'  Hi, My... named 'compressed-rtf' How to remove the ModuleNotFoundError: No module named 'compressed-rtf' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'compressed-rtf'
ModuleNotFoundError: No module named 'compressed-rtf'  Hi, My... named 'compressed-rtf' How to remove the ModuleNotFoundError: No module named 'compressed-rtf' error? Thanks   Hi, In your python
PDF to Image
PDF to Image  Java code to convert PDF to Image
pdf from i report
pdf from i report  I have a problem again with my report, i use I Report to make pdf file. but when the application running in java, pdf can't view. but in rtf format data can view. or can icon save like this to be dissapear
".txt" to sql with JDBC
".txt" to sql with JDBC  how to insert ".txt" into sql result[BLOB] with JDBC
Convesion of txt file to doc file.??????
Convesion of txt file to doc file.??????  how to convert text file to doc file using java
Maven Repository/Dependency: com.lowagie | itext-rtf
Maven Repository/Dependency of Group ID com.lowagie and Artifact ID itext-rtf. Latest version of com.lowagie:itext-rtf dependencies... 3 Tutorial Convert Maven project to Eclipse Web Project
Thread for reading txt file
Thread for reading txt file  how to use 3 thread to read 3 txt file? To create three threads for reading the file and three threads for getting the strings out of the queue and printing them. thanks
ModuleNotFoundError: No module named 'odoo8-addon-document-rtf-index'
ModuleNotFoundError: No module named 'odoo8-addon-document-rtf-index' ...: No module named 'odoo8-addon-document-rtf-index' How to remove the ModuleNotFoundError: No module named 'odoo8-addon-document-rtf-index' error
Maven Dependency itext-rtf >> 2.1.3
You should include the dependency code given in this page to add Maven Dependency of com.lowagie >> itext-rtf version2.1.3 in your project
Maven Dependency itext-rtf >> 2.1.5
You should include the dependency code given in this page to add Maven Dependency of com.lowagie >> itext-rtf version2.1.5 in your project
Maven Dependency itext-rtf >> 2.1.7
You should include the dependency code given in this page to add Maven Dependency of com.lowagie >> itext-rtf version2.1.7 in your project
Maven Dependency itext-rtf >> 2.1.4
You should include the dependency code given in this page to add Maven Dependency of com.lowagie >> itext-rtf version2.1.4 in your project
txt to cvs format
txt to cvs format  i am writing a simple program that read a text...; /*this program reads files from inpath and writes them to outpath as a single txt...(); } //this class converts the text file into binary static void convert(String to_convert
ModuleNotFoundError: No module named 'anchor-txt'
ModuleNotFoundError: No module named 'anchor-txt'  Hi, My Python... 'anchor-txt' How to remove the ModuleNotFoundError: No module named 'anchor-txt' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'pygame-txt'
ModuleNotFoundError: No module named 'pygame-txt'  Hi, My Python... 'pygame-txt' How to remove the ModuleNotFoundError: No module named 'pygame-txt' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'txt-util'
ModuleNotFoundError: No module named 'txt-util'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'txt-util' How to remove the ModuleNotFoundError: No module named 'txt-util
ModuleNotFoundError: No module named 'txt-wrangler'
ModuleNotFoundError: No module named 'txt-wrangler'  Hi, My Python... 'txt-wrangler' How to remove the ModuleNotFoundError: No module named 'txt-wrangler' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'asv_txt'
ModuleNotFoundError: No module named 'asv_txt'  Hi, My Python..._txt' How to remove the ModuleNotFoundError: No module named 'asv_txt... to install padas library. You can install asv_txt python with following command
ModuleNotFoundError: No module named 'anchor-txt'
ModuleNotFoundError: No module named 'anchor-txt'  Hi, My Python... 'anchor-txt' How to remove the ModuleNotFoundError: No module named 'anchor-txt' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'pygame-txt'
ModuleNotFoundError: No module named 'pygame-txt'  Hi, My Python... 'pygame-txt' How to remove the ModuleNotFoundError: No module named 'pygame-txt' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'pygame-txt'
ModuleNotFoundError: No module named 'pygame-txt'  Hi, My Python... 'pygame-txt' How to remove the ModuleNotFoundError: No module named 'pygame-txt' error? Thanks   Hi, In your python environment you

Ads