Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners document reading in java
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


prashant
document reading in java
1 Answer(s)      4 years and 5 months ago
Posted in : Java Beginners


Hi Dipak,
Can you tell me how to read pdf files in to java.i want convert pdf file in xml format through java coding.can you please help me?

Advertisement
View Answers

May 12, 2010 at 4:23 PM


Hi Friend,

Try the following code:

import java.io.*;
import java.util.*;
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;

public class ReadPDF {
public static void main(String[] args) throws IOException {
try {
Document document = new Document();
document.open();
PdfReader reader = new PdfReader("file.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);
StringBuffer buffer = new StringBuffer();
while (tokenizer.nextToken()) {
if (tokenizer.getTokenType() == PRTokeniser.TK_STRING) {
buffer.append(tokenizer.getStringValue());
}
}
String test=buffer.toString();
System.out.println(test);
}
catch (Exception e) {}
}
}

For the above code,you need itext-2.0.6.jar.

Thanks


Related Tutorials/Questions & Answers:
document reading in java - Java Beginners
document reading in java  Hi Dipak, Can you tell me how to read pdf files in to java.i want convert pdf file in xml format through java...(String[] args) throws IOException { try { Document document = new
word document reading - Development process
word document reading  I am in the midst of reading a word document while reading charts(EMF or WMF) pictures i am not able to do so can u suggest one class for this to accomplish
Advertisements
Reading a text file in java
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...Reading a text file in java  What is the code for Reading a text file
Reading files in Java
. Please provide me the example code for reading big text file in Java. What do you suggest for Reading files in Java? Thanks...Reading files in Java  I have to make a program in my project
Reading big file in Java
Reading big file in Java  How to read a big text file in Java program?   Hi, Read the complete tutorial at How to read big file line by line in java? Thanks
Java program for printing document
Java program for printing document  can u send me the java program for printing the office document? email: ibrahimbest@gmail.com
Best way to reading file in java
Best way to reading file in java  Hi, As a beginner I want to learn about Java programming and make a program for reading a text file in java. What is the best way for reading file in Java? Thanks
Reading an XML document using JDOM
Reading an XML document using JDOM   ..., it is a tree based Java api. JDOM represents an XML document as a tree composed... are some of the methods used in code given below for reading an XML document
reading excel sheet in java
reading excel sheet in java  can anyone tell me a proper java code to read excel sheet using poi   Here is a java code that reads an excel file using POI api and display the data on the console. import java.io.
web page reading in java
web page reading in java  i wanna read webpage in that i want to get the data from the particular tags like (,) and store into the data base...... can any body tell me the solution? plz urgnt. thanks and regards, jasti  
xml file reading using java
xml file reading using java  hi deepak I want to read some data from xml file and send that output to particular email address using java  ...(); Document doc = docBuilder.parse("roseindia.xml"); Element element
reading from pdf to java - Java Beginners
reading from pdf to java  How can i read the pdf file to strings in java. I need the methods of reading data from file and to place that data in the string, using java.   Hi Friend, We are providing you a code
Reading and Writing files - Java Beginners
Reading and Writing files  Hello, please help me to Develop a simple Java application that, when run, Welcomes the users and tells them the name of the last person to run the application, this information should be retrieved
problem in reading 10000 records in java
problem in reading 10000 records in java  Hi I have a huge records 10000 records ,while reading it show some error only i can able to read 2000 recds and need to display all the recods in jsper reports Thanks Gopi
Reading Files and Print - Java Beginners
Reading Files and Print  Hey Guys, I'm a beginner to java and I wanna write this program. I wanna create files including information of the students in my class. Each file contains a student's name, e-mail, school, hobby
Reading a file from Jar JAVA
Reading a file from Jar JAVA  I have added one excel sheet into a jar file. can anybody tell me how i can read that file. actually when i am running code from eclipse i able to read it but when i am adding that jar file
Reading a file from Jar JAVA
Reading a file from Jar JAVA  I have added one excel sheet into a jar file. can anybody tell me how i can read that file. actually when i am running code from eclipse i able to read it but when i am adding that jar file
Creating MS Word document in java - Struts
Creating MS Word document in java  I have one template in MS Word... content and also i need to set header and footer in doc file. That is, reading... you plz tell me how to do in java
Reading RDF file using Java code in Eclipse
Reading RDF file using Java code in Eclipse  Could you please tel me what this statement means - Model model = ModelFactory.createDefaultModel
How to merge two word document using java
How to merge two word document using java   how to merge two word document using java
How to merge two word document using java
How to merge two word document using java   how to merge two word document using java
export to word document - Java Beginners
export to word document  hi sir,when i am click on a button under the jtable,for example (print button),then i want to print that jtable in word document,automatically,plz provide program sir  Hi Friend, Try
reading and displaying svg file through java
reading and displaying svg file through java  sample program for reading a svg file
java code to open and display MS-word document
java code to open and display MS-word document  java code to open and display MS-word document
Reading text from image file - Java Beginners
Reading text from image file  How Read text from image file
Java example for Reading file into byte array
Java example for Reading file into byte array. You can then process the byte... in Java for reading file into byte array. Sometimes it becomes necessary to read a file into byte array for certain type of business processing. This Java
reading data using struts and jsp java
reading data using struts and jsp java  how can i read data entered by user into a textbox (jsp page) into struts action class ex emp id,so that after reading emp_id it can be read into struts action class for retrieving other
Writing to and reading from a binary file in java.
Writing to and reading from a binary file in java.  I have written the following code to convert an ASCII text file to a binary file: public static... work, but the records obtained after reading the binary file are much less than
initialise array by reading from file - Java Beginners
initialise array by reading from file  Hello, I wnat to know how i would initialise an array by reading a text file, which contains a simple pattern. for example the file may look as shown below, with the star character
How to make a design document for exception handling in java
How to make a design document for exception handling in java  How to make a design document for exception handling
Reading binary file into byte array in Java
Example code of reading binary file into byte array in Java This example shows you how to read a binary file into byte array from Java program. This type... of the Java program that reads the binary file into byte array: import java.io.
Advertisements
 

 

 

DMCA.com