public class RtfExternalGraphic extends RtfElement
Modifier and Type | Class and Description |
---|---|
static class |
RtfExternalGraphic.ExternalGraphicException
Exception thrown when an image file/URL cannot be read
|
Modifier and Type | Field and Description |
---|---|
protected int |
graphicCompressionRate
Graphic compression rate
|
protected int |
height
The height of the image (in pixels)
|
protected int |
heightDesired
The desired height (in twips)
|
protected boolean |
perCentH
Flag whether the desired height is a percentage
|
protected boolean |
perCentW
Flag whether the desired width is a percentage
|
protected boolean |
scaleUniform
Flag whether the image size shall be adjusted
|
protected URL |
url
The url of the image
|
protected int |
width
The width of the image (in pixels)
|
protected int |
widthDesired
The desired width (in twips)
|
attrib, parent, writer
Constructor and Description |
---|
RtfExternalGraphic(RtfContainer container,
Writer writer)
Default constructor.
|
RtfExternalGraphic(RtfContainer container,
Writer writer,
RtfAttributes attributes)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
getCompressionRate()
Gets the compression rate for the image in percent.
|
boolean |
isEmpty() |
boolean |
setCompressionRate(int percent)
Sets the compression rate for the image in percent.
|
void |
setCropping(int left,
int top,
int right,
int bottom)
Sets cropping values for all four edges for the \piccrop*N commands.
|
void |
setHeight(String theHeight)
Sets the desired height of the image.
|
void |
setHeightTwips(int twips)
Sets the desired height of the image.
|
void |
setImageData(byte[] data)
Sets the binary imagedata of the image.
|
void |
setScaling(String value)
Sets the flag whether the image size shall be adjusted.
|
void |
setUniformScaling(boolean uniform)
Sets the flag whether the image size shall be adjusted.
|
void |
setURL(String urlString)
Sets the url of the image.
|
void |
setWidth(String theWidth)
Sets the desired width of the image.
|
void |
setWidthTwips(int twips)
Sets the desired width of the image.
|
protected void |
writeRtfContent()
RtfElement override - catches ExternalGraphicException and writes a warning
message to the document if image cannot be read
|
protected void |
writeRtfContentWithException()
Writes the RTF content to m_writer - this one throws ExternalGraphicExceptions
|
close, getParentOfClass, getRtfAttributes, newLine, okToWriteRtf, toString, writeAttributes, writeControlWord, writeControlWordNS, writeExceptionInRtf, writeGroupMark, writeOneAttribute, writeOneAttributeNS, writeRtf, writeRtfPrefix, writeRtfSuffix, writeStarControlWord, writeStarControlWordNS
protected URL url
protected int height
protected int heightDesired
protected boolean perCentH
protected int width
protected int widthDesired
protected boolean perCentW
protected boolean scaleUniform
protected int graphicCompressionRate
public RtfExternalGraphic(RtfContainer container, Writer writer) throws IOException
container
- a RtfContainer
valuewriter
- a Writer
valueIOException
- for I/O problemspublic RtfExternalGraphic(RtfContainer container, Writer writer, RtfAttributes attributes) throws IOException
container
- a RtfContainer
valuewriter
- a Writer
valueattributes
- a RtfAttributes
valueIOException
- for I/O problemsprotected void writeRtfContent() throws IOException
writeRtfContent
in class RtfElement
IOException
- for I/O problemsprotected void writeRtfContentWithException() throws IOException
IOException
- On errorpublic void setHeight(String theHeight)
theHeight
- The desired image height (as a string in twips or as a percentage)public void setWidth(String theWidth)
theWidth
- The desired image width (as a string in twips or as a percentage)public void setWidthTwips(int twips)
twips
- The desired image width (in twips)public void setHeightTwips(int twips)
twips
- The desired image height (in twips)public void setScaling(String value)
value
- true image width or height shall be adjusted automatically\n
false no adjustmentpublic void setUniformScaling(boolean uniform)
uniform
- true image width or height shall be adjusted automatically\n
false no adjustmentpublic void setCropping(int left, int top, int right, int bottom)
left
- left cropping value (in twips)top
- top cropping value (in twips)right
- right cropping value (in twips)bottom
- bottom cropping value (in twips)public void setImageData(byte[] data) throws IOException
data
- binary imagedata as read from file.IOException
- On errorpublic void setURL(String urlString) throws IOException
urlString
- Image url like "file://..."IOException
- On errorpublic int getCompressionRate()
public boolean setCompressionRate(int percent)
percent
- Compression ratepublic boolean isEmpty()
isEmpty
in class RtfElement
Copyright © 2025 Apache Software Foundation. All rights reserved.