I am setting a margin for a pdf and checking if the contents of the page are exceeding the margin.
I am easily able to do that if the contents of a page are just text.
Here s what I am doing:
I am using TextMarginFinder. I will set the left margin values of the pdf based on the book size. and check with the finder.getLlx(); since finder.getLlx(); will get me the left most position of a text in that page.
TextMarginFinder finder;
if(leftmar>=finder.getLlx())
   {
        errormargin=1; //left margin error
        System.out.println("Page: "+i+"Margin Error:LeftMArginError ");
   }
But this does not work in case if the page contains an image. Although the image goes outside of the margin, I am not getting the error with the above code since the finder.getLlx(); function seems to work only for texts.
Two Questions:
1) While looping through the pages in pdf, if there is an image in that page, how can I check if that particular page contains an image?
2) If it contains an image, how can I obtain its extreme positions?
Update after mkl suggestion
     if(leftmar>=finder.getLlx())
{
    errormargin=1; //left margin error
    System.out.println("finder.getLlx() value ="+finder.getLlx()+", leftmar Value="+leftmar);
}
     if(rightmar<= finder.getUrx()){
            errormargin=1; //right margin error
            System.out.println("finder.getUrx() value ="+finder.getUrx()+", rightmar Value="+rightmar);
     }
if(margintop >= finder.getUry()){
    errormargin=3; //top margin error
    System.out.println("finder.getUry() value ="+finder.getUry()+", margintop Value="+margintop);
}
if(marginbottom >= finder.getLly()){
    errormargin=3; //bottom margin error
    System.out.println("finder.getLly() value ="+finder.getLly()+", marginbottom Value="+marginbottom);
}