You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't believe the library is supporting a CSS max-height property. I am new to the library but found the same problem in Flying Saucer when I was using that. I came up with this to fix it:
private static final class MaxWidthHeightSupportingRenderer extends ITextReplacedElementFactory {
MaxWidthHeightSupportingRenderer(ITextOutputDevice outputDevice) {
super(outputDevice);
}
@Override
public ReplacedElement createReplacedElement(LayoutContext c, BlockBox box, UserAgentCallback uac, int cssWidth, int cssHeight) {
Element e = box.getElement();
if (e != null && "img".equals(e.getNodeName())) {
String srcAttr = e.getAttribute("src");
if (srcAttr != null && srcAttr.length() > 0) {
FSImage fsImage = uac.getImageResource(srcAttr).getImage();
if (fsImage != null) {
if (cssWidth != -1 || cssHeight != -1) {
long maxWidth = box.getStyle().asLength(c, CSSName.MAX_WIDTH).value();
long maxHeight = box.getStyle().asLength(c, CSSName.MAX_HEIGHT).value();
if (cssHeight > maxHeight && cssHeight >= cssWidth) {
fsImage.scale(-1, (int) maxHeight);
} else if (cssWidth > maxWidth) {
fsImage.scale((int) maxWidth, -1);
} else {
fsImage.scale(cssWidth, cssHeight);
}
}
return new ITextImageElement(fsImage);
}
}
}
return super.createReplacedElement(c, box, uac, cssWidth, cssHeight);
}
}
I don't know how relevant that is to this project, as I just started using the library and need to learn more about how it works. Excited to see this though!
The text was updated successfully, but these errors were encountered:
I don't believe the library is supporting a CSS max-height property. I am new to the library but found the same problem in Flying Saucer when I was using that. I came up with this to fix it:
I don't know how relevant that is to this project, as I just started using the library and need to learn more about how it works. Excited to see this though!
The text was updated successfully, but these errors were encountered: