code: public void drawImage (final PDInlineImage inlineImage,
                           final float x,
                           final float y,
                           final float width,
                           final float height) throws IOException
    {
      if (inTextMode)
      {
        throw new IllegalStateException ("Error: drawImage is not allowed within a text block.");
      }
  
      saveGraphicsState ();
      transform (new Matrix (width, 0, 0, height, x, y));
  
      // create the image dictionary
      final StringBuilder sb = new StringBuilder ();
      sb.append ("BI");
  
      sb.append ("\n /W ");
      sb.append (inlineImage.getWidth ());
  
      sb.append ("\n /H ");
      sb.append (inlineImage.getHeight ());
  
      sb.append ("\n /CS ");
      sb.append ("/");
      sb.append (inlineImage.getColorSpace ().getName ());
  
      if (inlineImage.getDecode () != null && inlineImage.getDecode ().size () > 0)
      {
        sb.append ("\n /D ");
        sb.append ("[");
        for (final COSBase base : inlineImage.getDecode ())
        {
          sb.append (((COSNumber) base).intValue ());
          sb.append (" ");
        }
        sb.append ("]");
      }
  
      if (inlineImage.isStencil ())
      {
        sb.append ("\n /IM true");
      }
  
      sb.append ("\n /BPC ");
      sb.append (inlineImage.getBitsPerComponent ());
  
      // image dictionary
      write (sb.toString ());
      writeLine ();
  
      // binary data
      writeOperator ((byte) 'I', (byte) 'D');
      writeBytes (inlineImage.getData ());
      writeLine ();
      writeOperator ((byte) 'E', (byte) 'I');
  
      restoreGraphicsState ();
    }
docs: Draw an inline image at the x,y coordinates and a certain width and height.
  
  @param inlineImage
  The inline image to draw.
  @param x
  The x-coordinate to draw the inline image.
  @param y
  The y-coordinate to draw the inline image.
  @param width
  The width of the inline image to draw.
  @param height
  The height of the inline image to draw.
  @throws IOException
  If there is an error writing to the stream.
  @throws IllegalStateException
  If the method was called within a text block.