@@ -408,7 +408,7 @@ public void GxDrawBitMap(String bitmap, int left, int top, int right, int bottom
408408
409409 log .debug ("GxDrawBitMap -> '" + bitmap + "' [" + left + "," + top + "] - Size: (" + (right - left ) + "," + (bottom - top ) + ")" );
410410
411- if (image != null ) { // Si la imagen NO se encuentra, no hago nada
411+ if (image != null ) { // Si la imagen NO se encuentra, no hago nada
412412 float rightAux = (float )convertScale (right );
413413 float bottomAux = (float )convertScale (bottom );
414414 float leftAux = (float )convertScale (left );
@@ -417,11 +417,28 @@ public void GxDrawBitMap(String bitmap, int left, int top, int right, int bottom
417417 image .setAbsolutePosition (leftAux + leftMargin , this .pageSize .getTop () - bottomAux - topMargin - bottomMargin );
418418 if (aspectRatio == 0 )
419419 image .scaleAbsolute (rightAux - leftAux , bottomAux - topAux );
420- else
420+ else {
421421 image .scaleToFit (rightAux - leftAux , bottomAux - topAux );
422+ String verticalAlignment = System .getenv ("IMAGE_VERTICAL_ALIGNMENT" );
423+ verticalAlignment = (verticalAlignment != null ) ? verticalAlignment .toUpperCase () : "" ;
424+ if (verticalAlignment .equals ("TOP" ) || verticalAlignment .equals ("MIDDLE" ) || verticalAlignment .equals ("BOTTOM" )) {
425+ float imageHeight = image .getScaledHeight ();
426+ float yPosition ;
427+ if (verticalAlignment .equals ("TOP" )) {
428+ yPosition = this .pageSize .getTop () - topAux - imageHeight - topMargin - bottomMargin ;
429+ } else if (verticalAlignment .equals ("MIDDLE" )) {
430+ float centerY = (topAux + bottomAux ) / 2 ;
431+ yPosition = this .pageSize .getTop () - centerY - imageHeight / 2 - topMargin - bottomMargin ;
432+ } else {
433+ yPosition = this .pageSize .getTop () - bottomAux - topMargin - bottomMargin ;
434+ }
435+ image .setAbsolutePosition (leftAux + leftMargin , yPosition );
436+ }
437+ }
422438 PdfContentByte cb = writer .getDirectContent ();
423439 cb .addImage (image );
424440 }
441+
425442 }
426443 catch (DocumentException de ) {
427444 log .error ("GxDrawBitMap failed:" , de );
0 commit comments