*/
public PageFormat getPageFormat(int pageIndex)
{
PDPage page = (PDPage)getDocumentCatalog().getAllPages().get( pageIndex );
PDRectangle mediaBox = page.findMediaBox();
PageFormat format = new PageFormat();
Paper paper = new Paper();
//hmm the imageable area might need to be the CropBox instead
//of the media box???
double width=mediaBox.getWidth();
double height=mediaBox.getHeight();
if( width > height )
{
format.setOrientation( PageFormat.LANDSCAPE );
width=mediaBox.getHeight();
height=mediaBox.getWidth();
}
paper.setImageableArea( 0,0,width,height);
paper.setSize( width, height );
format.setPaper( paper );
return format;
}