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



Home Answers Viewqa Java-Beginners Extarct string from PDF
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


babu
Extarct string from PDF
2 Answer(s)      3 years and 11 months ago
Posted in : Java Beginners


how can i search a particular character from pdf? also extarct string from a pdf document??


Advertisement
View Answers

January 18, 2011 at 1:40 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 api.

Thanks



January 20, 2011 at 9:36 PM


Thanks for response.This code is working fine.But if there are any special charecter then this code is not working properly.If there are any solution please upload.



Related Tutorials/Questions & Answers:
Extarct string from PDF
Extarct string from PDF  how can i search a particular character from pdf? also extarct string from a pdf document
Extracting position of a particular string from a PDF
Extracting position of a particular string from a PDF  I have a pdf form. I want to knw the exact position(location) of a particular string of that form. Using iText I have extracted all the string from the PDF form, but nt able
Advertisements
Extarct equation
Extarct equation  Want to extarct equation of the form ax+by+c=0 from... org.apache.poi.hwpf.extractor.WordExtractor; public class FileRead{ public static void main(String... File("c:\\Hello.doc"); String st=""; FileInputStream fis=new FileInputStream
create pdf from jsongrid
create pdf from jsongrid  i need to create pdf from jsongrid in java struts2.. otherwise i need to create pdf from result set
pdf generate from jsp
pdf generate from jsp  how do i generate a pdf using jsp that should query the data from the database and write it into a pdf and download the same
Create PDF from java
Create PDF from java  Good afternoon, I have a problem how to create report. i want to create report in pdf file from my database in mysql. Now i... code to create pdf file from database call from java programming. thank you
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
reading from pdf
reading from pdf  how can i read specific words from pdf file?   Java Read pdf file import java.io.*; import java.util.*; import... static void main(String[] args) throws IOException { try
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
how to generate the pdf report from jsp
how to generate the pdf report from jsp  <%@page import... want to generate the pdf file from jsp page.I add the itext.jar to the libraries... not getting the pdf file.Any one please help me asap.Its very important
Generate unicode malayalam PDF from JSP
Generate unicode malayalam PDF from JSP   Hi, I want to generate a malayalam report in PDF format.I have generated a report in jsp.Now I want the same report to be saved as PDF in unicode malayalam font.I have tried to generate
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
how to add the scrollbar to the pdf page when generating the pdf file from jsp - JSP-Servlet
how to add the scrollbar to the pdf page when generating the pdf file from jsp  I am not able to see all the columns when i generated the pdf file from jsp.i have 12 colums so how to add the scrollbar
open pdf file in same jsp page and the pdf file should retrieved from database
open pdf file in same jsp page and the pdf file should retrieved from database  Hai all, I need code to open a pdf file in same jsp page(browser) while click on hyperlink And the file was located in database table. Can any
pdf file is having the 0 KB when generate the pdf file from jsp - JSP-Servlet
pdf file is having the 0 KB when generate the pdf file from jsp  Hi Friend, I am getting OKB pdf file .if i inserting the image into pdf file , i am getting the OKB pdf file now and also not able to open the pdf
Removing characters from a string
Removing characters from a string  Removing characters from a string...(String []args){ String str="Hello 123.you are At 3456"; String...() method removes all blank spaces in the string
How to set the pdfptable as pdf page header when generating the pdf from jsp page. - JSP-Servlet
How to set the pdfptable as pdf page header when generating the pdf from jsp page.  how to set the pdfptable column headers as a header of the documet.i need to display the column headers for every pdf page if pdf documt is 20
how to generate the pdf file with scroolbar from jsp age - JSP-Servlet
how to generate the pdf file with scroolbar from jsp age  How to generate the pdf file with scroolbar from jsp.i am not able to see the all the columns in pdf file now .it is very urgent for me plz help
Convert Text To PDF
required for the conversion of a text file into the pdf file from http... Convert Text To PDF       Here we are discussing the convertion of a text file into a pdf file
How to read PDF files created from Java thru VB Script
How to read PDF files created from Java thru VB Script  We have created the PDF file thru APache FOP but when we are unable to read the data thru... to read the FOP pdf? Is their any tool which convert the Apache FOP to Adobe PDF
Java dom from string
Java dom from string  Hi, How to create dom tree from string data? I am trying to search the example for java dom from string. Thanks   ... UpdateData { public static void main(String[] args) { String url="http
generating itext pdf from java application - Java Beginners
generating itext pdf from java application  hi, Is there any method in page events of itext to remove page numbers from pdf generated frm java application.  Hi friend, Read for more information. http
remove a substring from a string
remove a substring from a string  Please I jave an arraylist composed as follwoing [w1, w2, w3, w4, w1.w2.w3, w2.w3.w4, w3.w4, w2.w4, w1.w3, w1.w2] w2.w4 is a subset of w2.w3.w4 ?how I recognize it also w1.w3 is a subset
Removing character from a string in sql.
Removing character from a string in sql.  How to remove or replace character from a string
Removing character from a string in sql.
Removing character from a string in sql.  Removing special characters from a string in sql
remove comma from string php
remove comma from string php  How to remove the last comma from the string in PHP
Removing HTML from a Java String
Removing HTML from a Java String  Removing HTML from a Java String
remove comma from string php
remove comma from string php  How to remove the last comma from the string in PHP?   remove last comma from string names = names.replaceAll(",$", ""); //Or a simple substring: if (names.endsWith(",")) { names
Stripping of unwanted characters from string
Stripping of unwanted characters from string  how to strip off unwanted characters from a string   Hi Friend, Try this: public class StripCharacters { public String strip(String s) { String st
How to return a string from a JTextField
How to return a string from a JTextField  Hi, Am new to java, and am trying to get a string from a JTextField so that I can compare it with another String using either compare or equals or compareTo methods of the String class
query regarding exporting table from jsp page to pdf
query regarding exporting table from jsp page to pdf  hello i am displaying one table on my jsp page and i want to save that table in pdf file can u...="com.lowagie.text.pdf.*"%> <% String name[]=request.getParameterValues("name
Advertisements
 

 

 

DMCA.com