import com.etymon.pj.*;
import com.etymon.pj.object.*;
import com.etymon.pj.exception.*;
import java.util.Vector;
import com.etymon.pj.object.pagemark.XTj;

public class GetPDFInfo {
	 public static void main (String args[]) {
	 	try {
    	 	Pdf pdf = new Pdf(args[0]);
	        System.out.println("# of pages is " + pdf.getPageCount());
	 	    int y = pdf.getMaxObjectNumber();
	 	    System.out.println("Max no of objects : "+y);
	 	    for (int x=1; x <= y; x++) {

	 		 	PjObject obj = pdf.getObject(x);
	 		     /*if (obj instanceof PjInfo) {
	 		 	  System.out.println("Author: " + ((PjInfo)
                                                        obj).getAuthor());
	 		 	  System.out.println("Creator: " + ((PjInfo)
                                                        obj).getCreator());
	 		 	  System.out.println("Subject: " + ((PjInfo)
                                                        obj).getSubject());
	 		 	  System.out.println("Keywords: " + ((PjInfo)
                                                         obj).getKeywords());

	 		     }*/

	 		     if ( obj instanceof PjStream ) {

					 StreamParser sp = new StreamParser();

					 PjStream myPjStream = ( ( PjStream ) obj ).flateDecompress();

					 Vector myvec = sp.parse( myPjStream );

					 for ( int j = 0 ; j < myvec.size() ; j++ ) {
						 if ( myvec.get( j ) instanceof XTj ) {
							 PjString myPjString = ( ( XTj ) myvec.get( j ) ).getText();
							 System.out.println ( myPjString.getString() );
						 }
					 }
				 }


	 	    }
	 	}catch (java.io.IOException ex) {
 		    System.out.println(ex);
	 	}catch ( PdfFormatException pfe ) {
			pfe.printStackTrace();
		}catch ( PjException pje ) {
			pje.printStackTrace();
		}

	 }
}

