Skip to content

Commit 36b7b2a

Browse files
committed
Update max-width handling for images.
Update background with zero size warning: it is not an error. DEVSIX-1195
1 parent 6050baf commit 36b7b2a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

layout/src/main/java/com/itextpdf/layout/renderer/AbstractRenderer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ public void drawBackground(DrawContext drawContext) {
492492
Rectangle backgroundArea = applyMargins(bBox, false);
493493
if (backgroundArea.getWidth() <= 0 || backgroundArea.getHeight() <= 0) {
494494
Logger logger = LoggerFactory.getLogger(AbstractRenderer.class);
495-
logger.error(MessageFormatUtil.format(LogMessageConstant.RECTANGLE_HAS_NEGATIVE_OR_ZERO_SIZES, "background"));
495+
logger.warn(MessageFormatUtil.format(LogMessageConstant.RECTANGLE_HAS_NEGATIVE_OR_ZERO_SIZES, "background"));
496496
return;
497497
}
498498
boolean backgroundAreaIsClipped = false;
@@ -517,7 +517,7 @@ public void drawBackground(DrawContext drawContext) {
517517
backgroundImage.getImage().getWidth(), backgroundImage.getImage().getHeight());
518518
if (imageRectangle.getWidth() <= 0 || imageRectangle.getHeight() <= 0) {
519519
Logger logger = LoggerFactory.getLogger(AbstractRenderer.class);
520-
logger.error(MessageFormatUtil.format(LogMessageConstant.RECTANGLE_HAS_NEGATIVE_OR_ZERO_SIZES, "background-image"));
520+
logger.warn(MessageFormatUtil.format(LogMessageConstant.RECTANGLE_HAS_NEGATIVE_OR_ZERO_SIZES, "background-image"));
521521
return;
522522
}
523523
applyBorderBox(backgroundArea, true);

layout/src/main/java/com/itextpdf/layout/renderer/ImageRenderer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public ImageRenderer(Image image) {
106106
public LayoutResult layout(LayoutContext layoutContext) {
107107
LayoutArea area = layoutContext.getArea().clone();
108108
Rectangle layoutBox = area.getBBox().clone();
109-
Float retrievedWidth = retrieveWidth(layoutBox.getWidth());
109+
Float retrievedWidth = hasProperty(Property.WIDTH) ? retrieveWidth(layoutBox.getWidth()) : null;
110110

111111
List<Rectangle> floatRendererAreas = layoutContext.getFloatRendererAreas();
112112
float clearHeightCorrection = FloatingHelper.calculateClearHeightCorrection(this, floatRendererAreas, layoutBox);

0 commit comments

Comments
 (0)