*
* @throws IOException If there is an error drawing to the image.
*/
public BufferedImage convertToImage(int imageType, int resolution) throws IOException
{
PDRectangle mBox = findMediaBox();
float widthPt = mBox.getWidth();
float heightPt = mBox.getHeight();
float scaling = resolution / (float)DEFAULT_USER_SPACE_UNIT_DPI;
int widthPx = Math.round(widthPt * scaling);
int heightPx = Math.round(heightPt * scaling);
//TODO The following reduces accuracy. It should really be a Dimension2D.Float.
Dimension pageDimension = new Dimension( (int)widthPt, (int)heightPt );