Click here to Skip to main content
15,886,036 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am reading pdf through java but problem is like that i am reading 500 pages at that time they can read only 496 pages plz tell me what can i do
my code is bellow



Java
public class pdf1 {

	
	public static void main(String[] args) throws SQLException, ClassNotFoundException {
		try {

			PdfReader reader = new PdfReader("me1.pdf");
			
//			int n = reader.getNumberOfPages();
			 File outFile = new File("b.csv");
			int n=500;
			int count=0;
			 BufferedWriter writer = new BufferedWriter(new FileWriter(outFile));
			
			 for(int i=1;i<=n;i++)
			 {
			 String str=PdfTextExtractor.getTextFromPage(reader, i);
			 System.out.println(str);
			 writer.write(str);
			 count++;
			 }
			 System.out.println(count);

	} catch (IOException e) {
			e.printStackTrace();
		}

	}

}
Posted

1 solution

You should use getNumberOfPages[^] to check the actual page count of the document.
 
Share this answer
 
Comments
baliram bhande 5-Feb-14 4:57am    
ya . i am checked that but problem is that page count is 852 and they can read actual 845 pages .that data can be saved in .csv file
Richard MacCutchan 5-Feb-14 5:13am    
Sorry, but it is impossible to guess what is happening, you need to collect more detailed information.
baliram bhande 5-Feb-14 7:09am    
is there any method in java to read pdf file line by line .
Richard MacCutchan 5-Feb-14 7:29am    
I don't know, but if you follow the link I gave you it takes you to the documentation, where you can see what other methods are available.
baliram bhande 5-Feb-14 8:02am    
thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900