Package com.itextpdf.layout.element
Class Image
- All Implemented Interfaces:
-
IAbstractElement
,IElement
,ILeafElement
,IPropertyContainer
,IAccessibleElement
- Direct Known Subclasses:
-
SvgImage
A layout element that represents an image for inclusion in the document model.
-
Field Summary
Fields inherited from class com.itextpdf.layout.element.AbstractElement
childElements, nextRenderer, styles
Fields inherited from class com.itextpdf.layout.ElementPropertyContainer
properties
-
Constructor Summary
ConstructorDescriptionCreates anImage
from an image resource, read in from a file with the iText I/O module.Creates anImage
from an image resource, read in from a file with the iText I/O module, on a fixed position.Creates anImage
from an image resource, read in from a file with the iText I/O module, with a custom width and on a fixed position.Image
(PdfFormXObject xObject) Creates anImage
from a form XObject, the representation of a form in PDF syntax.Image
(PdfFormXObject xObject, float left, float bottom) Creates anImage
from a form XObject, the representation of a form in PDF syntax.Image
(PdfImageXObject xObject) Creates anImage
from an image XObject, the representation of an image in PDF syntax.Image
(PdfImageXObject xObject, float width) Creates anImage
from an image XObject, the representation of an image in PDF syntax, with a custom width.Image
(PdfImageXObject xObject, float left, float bottom) Creates anImage
from an image XObject, the representation of an image in PDF syntax, on a fixed position.Image
(PdfImageXObject xObject, float left, float bottom, float width) Creates anImage
from an image XObject, the representation of an image in PDF syntax, with a custom width and on a fixed position. -
Method Summary
Modifier and TypeMethodDescriptionGets theaccessibility properties
.float
Gets height of the image.float
Gets scaled height of the image.float
Gets scaled width of the image.float
Gets width of the image.Gets the current bottom margin width of the image.Gets the current left margin width of the element.Gets the current right margin width of the image.Gets the current top margin width of the image.Retrieves theObjectFit
mode for the image.Gets the current bottom padding width of the image.Gets the current left padding width of the image.Gets the current right padding width of the image.Gets the current top padding width of the image.getWidth()
Gets the width property of the image.Gets the XObject contained in this image objectprotected IRenderer
Creates new renderer instance.scale
(float horizontalScaling, float verticalScaling) Scale the image relative to its default size.scaleAbsolute
(float fitWidth, float fitHeight) Scale the image to an absolute size.scaleToFit
(float fitWidth, float fitHeight) Scale the image to an absolute size.setAutoScale
(boolean autoScale) Sets the autoscale property for both width and height.setAutoScaleHeight
(boolean autoScale) Sets the autoscale property for the height of the image.setAutoScaleWidth
(boolean autoScale) Sets the autoscale property for the width of the image.setFixedPosition
(float left, float bottom) Sets values for a absolute repositioning of the Element.setFixedPosition
(int pageNumber, float left, float bottom) Sets values for a absolute repositioning of the Element, on a specific page.setHeight
(float height) Sets the height property of the image, measured in points.Sets the height property of the image with aUnitValue
.setMarginBottom
(float value) Sets the bottom margin width of the image.setMarginLeft
(float value) Sets the left margin width of the element.setMarginRight
(float value) Sets the right margin width of the image.setMargins
(float marginTop, float marginRight, float marginBottom, float marginLeft) Sets the margins around the image to a series of new widths.setMarginTop
(float value) Sets the top margin width of the image.setMaxHeight
(float maxHeight) Sets the max-height property of the image, measured in points.setMaxHeight
(UnitValue maxHeight) Sets the max-height property of the image with aUnitValue
.setMaxWidth
(float maxWidth) Sets the max-width property of the image, measured in points.setMaxWidth
(UnitValue maxWidth) Sets the max-width property of the image with aUnitValue
.setMinHeight
(float minHeight) Sets the min-height property of the image, measured in points.setMinHeight
(UnitValue minHeight) Sets the min-height property of the image with aUnitValue
.setMinWidth
(float minWidth) Sets the min-width property of the image, measured in points.setMinWidth
(UnitValue minWidth) Sets the min-width property of the image with aUnitValue
.Give this element a neutral role.setObjectFit
(ObjectFit objectFit) Sets an object-fit mode for the image.setPadding
(float commonPadding) Sets all paddings around the image to the same width.setPaddingBottom
(float value) Sets the bottom padding width of the image.setPaddingLeft
(float value) Sets the left padding width of the image.setPaddingRight
(float value) Sets the right padding width of the image.setPaddings
(float paddingTop, float paddingRight, float paddingBottom, float paddingLeft) Sets the paddings around the image to a series of new widths.setPaddingTop
(float value) Sets the top padding width of the image.setRotationAngle
(double radAngle) Sets the rotation radAngle.setWidth
(float width) Sets the width property of the image, measured in points.Sets the width property of the image with aUnitValue
.Methods inherited from class com.itextpdf.layout.element.AbstractElement
addStyle, createRendererSubTree, getChildren, getProperty, getRenderer, hasProperty, isEmpty, setAction, setNextRenderer, setPageNumber
Methods inherited from class com.itextpdf.layout.ElementPropertyContainer
deleteOwnProperty, getDefaultProperty, getOwnProperty, getSplitCharacters, getStrokeColor, getStrokeWidth, getTextRenderingMode, hasOwnProperty, setBackgroundColor, setBackgroundColor, setBackgroundColor, setBackgroundColor, setBackgroundImage, setBackgroundImage, setBaseDirection, setBorder, setBorderBottom, setBorderBottomLeftRadius, setBorderBottomRightRadius, setBorderLeft, setBorderRadius, setBorderRight, setBorderTop, setBorderTopLeftRadius, setBorderTopRightRadius, setCharacterSpacing, setDestination, setFixedPosition, setFixedPosition, setFixedPosition, setFixedPosition, setFont, setFontColor, setFontColor, setFontColor, setFontFamily, setFontFamily, setFontKerning, setFontScript, setFontSize, setHorizontalAlignment, setHyphenation, setLineThrough, setOpacity, setProperty, setRelativePosition, setSplitCharacters, setStrokeColor, setStrokeWidth, setTextAlignment, setTextRenderingMode, setUnderline, setUnderline, setUnderline, setUnderline, setWordSpacing, simulateBold, simulateItalic
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.itextpdf.layout.element.IElement
createRendererSubTree, getRenderer, setNextRenderer
Methods inherited from interface com.itextpdf.layout.IPropertyContainer
deleteOwnProperty, getDefaultProperty, getOwnProperty, getProperty, hasOwnProperty, hasProperty, setProperty
-
Field Details
-
xObject
-
tagProperties
-
-
Constructor Details
-
Image
Creates anImage
from an image XObject, the representation of an image in PDF syntax.- Parameters:
-
xObject
- an internalPdfImageXObject
-
Image
Creates anImage
from a form XObject, the representation of a form in PDF syntax.- Parameters:
-
xObject
- an internalPdfFormXObject
-
Image
Creates anImage
from an image XObject, the representation of an image in PDF syntax, with a custom width.- Parameters:
-
xObject
- an internalPdfImageXObject
-
width
- a float value
-
Image
Creates anImage
from an image XObject, the representation of an image in PDF syntax, with a custom width and on a fixed position.- Parameters:
-
xObject
- an internalPdfImageXObject
-
left
- a float value representing the horizontal offset of the lower left corner of the image -
bottom
- a float value representing the vertical offset of the lower left corner of the image -
width
- a float value
-
Image
Creates anImage
from an image XObject, the representation of an image in PDF syntax, on a fixed position.- Parameters:
-
xObject
- an internalPdfImageXObject
-
left
- a float value representing the horizontal offset of the lower left corner of the image -
bottom
- a float value representing the vertical offset of the lower left corner of the image
-
Image
Creates anImage
from a form XObject, the representation of a form in PDF syntax.- Parameters:
-
xObject
- an internalPdfFormXObject
-
left
- a float value representing the horizontal offset of the lower left corner of the form -
bottom
- a float value representing the vertical offset of the lower left corner of the form
-
Image
Creates anImage
from an image resource, read in from a file with the iText I/O module.- Parameters:
-
img
- an internal representation of theimage resource
-
Image
Creates anImage
from an image resource, read in from a file with the iText I/O module, on a fixed position.- Parameters:
-
img
- an internal representation of theimage resource
-
left
- a float value representing the horizontal offset of the lower left corner of the image -
bottom
- a float value representing the vertical offset of the lower left corner of the image
-
Image
Creates anImage
from an image resource, read in from a file with the iText I/O module, with a custom width and on a fixed position.- Parameters:
-
img
- an internal representation of theimage resource
-
left
- a float value representing the horizontal offset of the lower left corner of the image -
bottom
- a float value representing the vertical offset of the lower left corner of the image -
width
- a float value
-
-
Method Details
-
getXObject
Gets the XObject contained in this image object- Returns:
-
a
PdfXObject
-
setRotationAngle
Sets the rotation radAngle.- Parameters:
-
radAngle
- a value in radians - Returns:
- this element
-
getMarginLeft
Gets the current left margin width of the element.- Returns:
-
the left margin width, as a
UnitValue
object
-
setMarginLeft
Sets the left margin width of the element.- Parameters:
-
value
- the new left margin width - Returns:
- this element
-
getMarginRight
Gets the current right margin width of the image.- Returns:
-
the right margin width, as a
UnitValue
object
-
setMarginRight
Sets the right margin width of the image.- Parameters:
-
value
- the new right margin width - Returns:
- this image
-
getMarginTop
Gets the current top margin width of the image.- Returns:
-
the top margin width, as a
UnitValue
object
-
setMarginTop
Sets the top margin width of the image.- Parameters:
-
value
- the new top margin width - Returns:
- this image
-
getMarginBottom
Gets the current bottom margin width of the image.- Returns:
-
the bottom margin width, as a
UnitValue
object
-
setMarginBottom
Sets the bottom margin width of the image.- Parameters:
-
value
- the new bottom margin width - Returns:
- this image
-
setMargins
Sets the margins around the image to a series of new widths.- Parameters:
-
marginTop
- the new margin top width -
marginRight
- the new margin right width -
marginBottom
- the new margin bottom width -
marginLeft
- the new margin left width - Returns:
- this image
-
getPaddingLeft
Gets the current left padding width of the image.- Returns:
-
the left padding width, as a
UnitValue
object
-
setPaddingLeft
Sets the left padding width of the image.- Parameters:
-
value
- the new left padding width - Returns:
- this image
-
getPaddingRight
Gets the current right padding width of the image.- Returns:
-
the right padding width, as a
UnitValue
object
-
setPaddingRight
Sets the right padding width of the image.- Parameters:
-
value
- the new right padding width - Returns:
- this image
-
getPaddingTop
Gets the current top padding width of the image.- Returns:
-
the top padding width, as a
UnitValue
object
-
setPaddingTop
Sets the top padding width of the image.- Parameters:
-
value
- the new top padding width - Returns:
- this image
-
getPaddingBottom
Gets the current bottom padding width of the image.- Returns:
-
the bottom padding width, as a
UnitValue
object
-
setPaddingBottom
Sets the bottom padding width of the image.- Parameters:
-
value
- the new bottom padding width - Returns:
- this image
-
setPadding
Sets all paddings around the image to the same width.- Parameters:
-
commonPadding
- the new padding width - Returns:
- this image
-
setPaddings
public Image setPaddings(float paddingTop, float paddingRight, float paddingBottom, float paddingLeft) Sets the paddings around the image to a series of new widths.- Parameters:
-
paddingTop
- the new padding top width -
paddingRight
- the new padding right width -
paddingBottom
- the new padding bottom width -
paddingLeft
- the new padding left width - Returns:
- this image
-
scale
Scale the image relative to its default size.- Parameters:
-
horizontalScaling
- the horizontal scaling coefficient. default value 1 = 100% -
verticalScaling
- the vertical scaling coefficient. default value 1 = 100% - Returns:
- this element
-
scaleToFit
Scale the image to an absolute size. This method will preserve the width-height ratio of the image.- Parameters:
-
fitWidth
- the new maximum width of the image -
fitHeight
- the new maximum height of the image - Returns:
- this element
-
scaleAbsolute
Scale the image to an absolute size. This method will not preserve the width-height ratio of the image.- Parameters:
-
fitWidth
- the new absolute width of the image -
fitHeight
- the new absolute height of the image - Returns:
- this element
-
setAutoScale
Sets the autoscale property for both width and height.- Parameters:
-
autoScale
- whether or not to let the image resize automatically - Returns:
- this image
-
setAutoScaleHeight
Sets the autoscale property for the height of the image. Is currently bugged and will not work as expected.- Parameters:
-
autoScale
- whether or not to let the image height resize automatically - Returns:
- this image
-
setAutoScaleWidth
Sets the autoscale property for the width of the image.- Parameters:
-
autoScale
- whether or not to let the image width resize automatically - Returns:
- this image
-
setFixedPosition
Sets values for a absolute repositioning of the Element. Also has as a side effect that the Element'sProperty.POSITION
is changed tofixed
.- Parameters:
-
left
- horizontal position on the page -
bottom
- vertical position on the page - Returns:
- this image.
-
setFixedPosition
Sets values for a absolute repositioning of the Element, on a specific page. Also has as a side effect that the Element'sProperty.POSITION
is changed tofixed
.- Parameters:
-
pageNumber
- the page where the element must be positioned -
left
- horizontal position on the page -
bottom
- vertical position on the page - Returns:
- this Element.
-
getImageWidth
public float getImageWidth()Gets width of the image. It returns width of image or form XObject, not the width set by one of the #setWidth methods- Returns:
- the original width of the image
-
getImageHeight
public float getImageHeight()Gets height of the image. It returns height of image or form XObject, not the height set by one of the #setHeight methods- Returns:
- the original height of the image
-
setHeight
Sets the height property of the image, measured in points.- Parameters:
-
height
- a value measured in points. - Returns:
- this image.
-
setHeight
Sets the height property of the image with aUnitValue
.- Parameters:
-
height
- a value measured in points. - Returns:
- this image.
-
setMaxHeight
Sets the max-height property of the image, measured in points.- Parameters:
-
maxHeight
- a value measured in points. - Returns:
- this image.
-
setMaxHeight
Sets the max-height property of the image with aUnitValue
.- Parameters:
-
maxHeight
- a value measured in points. - Returns:
- this image.
-
setMinHeight
Sets the min-height property of the image, measured in points.- Parameters:
-
minHeight
- a value measured in points. - Returns:
- this image.
-
setMinHeight
Sets the min-height property of the image with aUnitValue
.- Parameters:
-
minHeight
- a value measured in points. - Returns:
- this image.
-
setMaxWidth
Sets the max-width property of the image, measured in points.- Parameters:
-
maxWidth
- a value measured in points. - Returns:
- this image.
-
setMaxWidth
Sets the max-width property of the image with aUnitValue
.- Parameters:
-
maxWidth
- a value measured in points. - Returns:
- this image.
-
setMinWidth
Sets the min-width property of the image, measured in points.- Parameters:
-
minWidth
- a value measured in points. - Returns:
- this image.
-
setMinWidth
Sets the min-width property of the image with aUnitValue
.- Parameters:
-
minWidth
- a value measured in points. - Returns:
- this image.
-
setWidth
Sets the width property of the image, measured in points.- Parameters:
-
width
- a value measured in points. - Returns:
- this image.
-
setWidth
Sets the width property of the image with aUnitValue
.- Parameters:
-
width
- aUnitValue
object - Returns:
- this image.
-
getWidth
Gets the width property of the image.- Returns:
- the width of the element, with a value and a measurement unit.
- See Also:
-
getImageScaledWidth
public float getImageScaledWidth()Gets scaled width of the image.- Returns:
- the current scaled width
-
getImageScaledHeight
public float getImageScaledHeight()Gets scaled height of the image.- Returns:
- the current scaled height
-
setObjectFit
Sets an object-fit mode for the image.- Parameters:
-
objectFit
- is theObjectFit
mode - Returns:
- this image
-
getObjectFit
Retrieves theObjectFit
mode for the image.- Returns:
-
an object-fit mode for the image if it was set and default value
ObjectFit.FILL
otherwise
-
getAccessibilityProperties
Description copied from interface:IAccessibleElement
Gets theaccessibility properties
. See alsoIAccessibleElement
.- Specified by:
-
getAccessibilityProperties
in interfaceIAccessibleElement
- Returns:
- an interface that allows to specify properties of a tagged element in Tagged PDF.
-
setNeutralRole
Give this element a neutral role. See alsoAccessibilityProperties.setRole(String)
.- Returns:
- this Element
-
makeNewRenderer
Description copied from class:AbstractElement
Creates new renderer instance.- Specified by:
-
makeNewRenderer
in classAbstractElement<Image>
- Returns:
-
new
IRenderer
-