hi all,
i have to get the number of pages for a pdf document using java.
i checked in java pdf api library but i have not get the correct idea. can anybody help for my work pls.
if u have code for that na pls send me.
advance thanks

What "java pdf library" did you check and provide the code for the way you checked it, because iText can do this easily. Although I don't really know why you need to know the number of pages in order to simply feed the document to a browser (which is what all your other posts about this have been about so far).

And don't simply tell me that you have already tried this, show me.

hi masijade,
this is another project.
1) assume that a folder contains five pdf documents,
2) i have to check that five docs whether they are corrupted,
3) i have to compile it from 1 to 5.
4) if the third file is corrupted i have to throw an exception error to inform the file is corrupted.
5) and it continues to check the next document.
for this process only i am using the getting the page property.
now help me by giving some idea about this process.
i have to do this process using java
advance thanks....

package com.adobe.acrobat;

import java.awt.*;

import java.io.*;

public class PDFViewer {
public PDFViewer() throws java.lang.Exception {

public void viewPDFDocument() {
try {
String Viewer;
Frame frame = new Frame("PDF Viewer");
frame.setLayout(new BorderLayout());

Viewer viewer = new Viewer();

frame.add(viewer, BorderLayout.CENTER);
frame.add(new Label("PDF Document in Adobe Acrobat Viewer",Label.CENTER), BorderLayout.NORTH);

InputStream input = new FileInputStream(new File("C:\\interface1.pdf"));
viewer.setProperty("Default_Page_Layout", "SinglePage");
viewer.setProperty("Default_Zoom_Type", "FitPage");
viewer.setProperty("Default_Magnification", "100");
System.out.println("Page Count: " + viewer.getPageCount());
System.out.println("Current Page: " + viewer.getCurrentPage());
frame.setSize(400, 500);
OutputStream output=new FileOutputStream(new File("C:/Adobe/output.txt"));
PrintWriter printWriter=new PrintWriter(output);
} catch (java.lang.Exception e) {
public static void main(String[] argv) {
try {
PDFViewer pdfViewer = new PDFViewer();
} catch (java.lang.Exception e) {

i have a error in this line********Viewer viewer = new Viewer();
help me pls

What error?

And where is the import for Viewer?

Don't tell me that you are trying to use the same package that the iText classes use, and so you think you can reference their classes without an import.

It doesn't work that way. Put your classes in their own package and import the iText classes.

also use code tags when posting code, it makes it easier on the eyes

k k k k acidu....
thanks for ur kind kind kind information.
(0 0)

acidburn is right, you should use code tags to post your code and with number of post you made this should betrivial now...

to your question pdf & java I would recommend you to look at iText. I found it quete useful, they have large forum and plenty of tutorials.
iText home page
iText API
iText mailing forum

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.