Class RtfExternalGraphic
java.lang.Object
org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement
org.apache.fop.render.rtf.rtflib.rtfdoc.RtfExternalGraphic
Creates an RTF image from an external graphic file.
This class belongs to the fo:external-graphic tag processing.
Supports relative path like "../test.gif", too (01-08-24)
Limitations: Only the image types PNG, JPEG and EMF are supported The GIF is supported, too, but will be converted to JPG Only the attributes SRC (required), WIDTH, HEIGHT, SCALING are supported The SCALING attribute supports (uniform | non-uniform) Known Bugs: If the emf image has a desired size, the image will be clipped The emf, jpg, png image will not be displayed in correct size This work was originally authored by Andreas Putz This work was originally authored by Gianugo Rabellino gianugo@rabellino.it
Supports relative path like "../test.gif", too (01-08-24)
Limitations: Only the image types PNG, JPEG and EMF are supported The GIF is supported, too, but will be converted to JPG Only the attributes SRC (required), WIDTH, HEIGHT, SCALING are supported The SCALING attribute supports (uniform | non-uniform) Known Bugs: If the emf image has a desired size, the image will be clipped The emf, jpg, png image will not be displayed in correct size This work was originally authored by Andreas Putz This work was originally authored by Gianugo Rabellino gianugo@rabellino.it
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Exception thrown when an image file/URL cannot be read -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
Graphic compression rateprotected int
The height of the image (in pixels)protected int
The desired height (in twips)protected boolean
Flag whether the desired height is a percentageprotected boolean
Flag whether the desired width is a percentageprotected boolean
Flag whether the image size shall be adjustedprotected URL
The url of the imageprotected int
The width of the image (in pixels)protected int
The desired width (in twips)Fields inherited from class org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement
attrib, parent, writer
-
Constructor Summary
ConstructorsConstructorDescriptionRtfExternalGraphic
(RtfContainer container, Writer writer) Default constructor.RtfExternalGraphic
(RtfContainer container, Writer writer, RtfAttributes attributes) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionint
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
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
Sets the url of the image.void
Sets the desired width of the image.void
setWidthTwips
(int twips) Sets the desired width of the image.protected void
RtfElement override - catches ExternalGraphicException and writes a warning message to the document if image cannot be readprotected void
Writes the RTF content to m_writer - this one throws ExternalGraphicExceptionsMethods inherited from class org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement
close, getParentOfClass, getRtfAttributes, newLine, okToWriteRtf, toString, writeAttributes, writeControlWord, writeControlWordNS, writeExceptionInRtf, writeGroupMark, writeOneAttribute, writeOneAttributeNS, writeRtf, writeRtfPrefix, writeRtfSuffix, writeStarControlWord, writeStarControlWordNS
-
Field Details
-
url
The url of the image -
height
protected int heightThe height of the image (in pixels) -
heightDesired
protected int heightDesiredThe desired height (in twips) -
perCentH
protected boolean perCentHFlag whether the desired height is a percentage -
width
protected int widthThe width of the image (in pixels) -
widthDesired
protected int widthDesiredThe desired width (in twips) -
perCentW
protected boolean perCentWFlag whether the desired width is a percentage -
scaleUniform
protected boolean scaleUniformFlag whether the image size shall be adjusted -
graphicCompressionRate
protected int graphicCompressionRateGraphic compression rate
-
-
Constructor Details
-
RtfExternalGraphic
Default constructor. Create an RTF element as a child of given container.- Parameters:
container
- aRtfContainer
valuewriter
- aWriter
value- Throws:
IOException
- for I/O problems
-
RtfExternalGraphic
public RtfExternalGraphic(RtfContainer container, Writer writer, RtfAttributes attributes) throws IOException Default constructor.- Parameters:
container
- aRtfContainer
valuewriter
- aWriter
valueattributes
- aRtfAttributes
value- Throws:
IOException
- for I/O problems
-
-
Method Details
-
writeRtfContent
RtfElement override - catches ExternalGraphicException and writes a warning message to the document if image cannot be read- Specified by:
writeRtfContent
in classRtfElement
- Throws:
IOException
- for I/O problems
-
writeRtfContentWithException
Writes the RTF content to m_writer - this one throws ExternalGraphicExceptions- Throws:
IOException
- On error
-
setHeight
Sets the desired height of the image.- Parameters:
theHeight
- The desired image height (as a string in twips or as a percentage)
-
setWidth
Sets the desired width of the image.- Parameters:
theWidth
- The desired image width (as a string in twips or as a percentage)
-
setWidthTwips
public void setWidthTwips(int twips) Sets the desired width of the image.- Parameters:
twips
- The desired image width (in twips)
-
setHeightTwips
public void setHeightTwips(int twips) Sets the desired height of the image.- Parameters:
twips
- The desired image height (in twips)
-
setScaling
Sets the flag whether the image size shall be adjusted.- Parameters:
value
- true image width or height shall be adjusted automatically\n false no adjustment
-
setUniformScaling
public void setUniformScaling(boolean uniform) Sets the flag whether the image size shall be adjusted.- Parameters:
uniform
- true image width or height shall be adjusted automatically\n false no adjustment
-
setCropping
public void setCropping(int left, int top, int right, int bottom) Sets cropping values for all four edges for the \piccrop*N commands. A positive value crops toward the center of the picture; a negative value crops away from the center, adding a space border around the picture- Parameters:
left
- left cropping value (in twips)top
- top cropping value (in twips)right
- right cropping value (in twips)bottom
- bottom cropping value (in twips)
-
setImageData
Sets the binary imagedata of the image.- Parameters:
data
- binary imagedata as read from file.- Throws:
IOException
- On error
-
setURL
Sets the url of the image.- Parameters:
urlString
- Image url like "file://..."- Throws:
IOException
- On error
-
getCompressionRate
public int getCompressionRate()Gets the compression rate for the image in percent.- Returns:
- Compression rate
-
setCompressionRate
public boolean setCompressionRate(int percent) Sets the compression rate for the image in percent.- Parameters:
percent
- Compression rate- Returns:
- true if the compression rate is valid (0..100), false if invalid
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in classRtfElement
- Returns:
- true if this element would generate no "useful" RTF content
-