package test.pdf;

import com.lowagie.text.pdf.*;
import com.lowagie.text.pdf.parser.*;
import java.io.IOException;
import java.net.*;

public class PdfParser extends PdfContentStreamProcessor {
  public PdfParser() 
  throws IOException {
    PdfReader reader = new PdfReader(new URL("http://www.dallascad.org/forms/2008rate.pdf"));
    PdfDictionary pageDic = reader.getPageN(2);
    PdfDictionary resourcesDic = pageDic.getAsDict(PdfName.RESOURCES);
    processContent(reader.getPageContent(2), resourcesDic);        
  }

  public void displayText(String text, Matrix nextTextMatrix) {
    if( "Taxes for this entity are collected by the Dallas County Tax Office.".equals(text) ||
        "If the optional homestead exemption is offered, it must be a minimum of $5,000.".equals(text) )
      System.out.println(text+" x: "+getCurrentTextMatrix().get(Matrix.I31)+" y: "+getCurrentTextMatrix().get(Matrix.I32));
  }

  public static void main(String[] args) 
  throws Exception {
    new PdfParser();
  }
}
