//draw the map (at a high resolution as specified above)
ApplicationGIS.drawMap(drawMapParameter);
Image img = Image.getInstance(bufferedImage2ByteArray(imageOfRastersOnly));
//scale the image down to fit into the page
img.scaleAbsolute(mapBoundsInTemplate.width, mapBoundsInTemplate.height);
//set the location of the image
int left = mapBoundsInTemplate.x;
int bottom = pageSize.height - mapBoundsInTemplate.height - mapBoundsInTemplate.y;
img.setAbsolutePosition(left, bottom); //(0,0) is bottom left in the PDF coordinate system