@@ -408,7 +408,7 @@ public void GxDrawBitMap(String bitmap, int left, int top, int right, int bottom
408
408
409
409
log .debug ("GxDrawBitMap -> '" + bitmap + "' [" + left + "," + top + "] - Size: (" + (right - left ) + "," + (bottom - top ) + ")" );
410
410
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
412
412
float rightAux = (float )convertScale (right );
413
413
float bottomAux = (float )convertScale (bottom );
414
414
float leftAux = (float )convertScale (left );
@@ -417,11 +417,28 @@ public void GxDrawBitMap(String bitmap, int left, int top, int right, int bottom
417
417
image .setAbsolutePosition (leftAux + leftMargin , this .pageSize .getTop () - bottomAux - topMargin - bottomMargin );
418
418
if (aspectRatio == 0 )
419
419
image .scaleAbsolute (rightAux - leftAux , bottomAux - topAux );
420
- else
420
+ else {
421
421
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
+ }
422
438
PdfContentByte cb = writer .getDirectContent ();
423
439
cb .addImage (image );
424
440
}
441
+
425
442
}
426
443
catch (DocumentException de ) {
427
444
log .error ("GxDrawBitMap failed:" , de );
0 commit comments