title: Centre-align images in generated iText PDF document
body: <p>I am using a library "com.itextpdf:itextg" for generating PDF files. My requirement is to add images to PDF file in A4 format, One Image per page. </p>
  
  <pre><code>ByteArrayOutputStream stream = new ByteArrayOutputStream();
  bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
  Image image = Image.getInstance(stream.toByteArray());
  image.scaleToFit(PageSize.A4);
  document.add(image);
  </code></pre>
  
  <p>By default, images are added as top-aligned and some space is left vacant at bottom of the PDF document page.</p>
  
  <p>I want to centre-align Images, so that equal space is left from all sides and the image is placed at the centre.</p>
  
  <p>I know we have a method setAbsolutePosition, but it requires absoluteX and absoluteY. I needed something relative like CENTRE_HORIZONTAL and CENTRE_VERTICAL. Can someone help in generating PDF with images centre-aligned (vertically and horizontally)?</p>