|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.faceless.pdf2.PDFAnnotation
org.faceless.pdf2.AnnotationText
public final class AnnotationText
This class represents the type of PDFAnnotation
created by the
"Text Markup" tool in Acrobat. This is simply a box which may contain
one or more lines of text.
Constructor Summary | |
---|---|
AnnotationText()
Create a new Text annotation |
Method Summary | |
---|---|
PDFStyle |
getBackgroundStyle()
Get the background style for the annotation |
float[] |
getCallout()
Get the callout points, as set by setCallout(float[]) |
String |
getCalloutEnding()
Get the type of Line-Ending, as set by setCalloutEnding(java.lang.String) |
Color |
getColor()
Return the background color of the annotation - since 2.11, the equivalent of calling getBackgroundStyle().getFillColor() |
float[] |
getContentRectangle()
Return the rectangle of the content of this annotation. |
String |
getRichTextContents()
Get the rich-text content of this annotation if specified, or null if only
plain-text content is available |
PDFStyle |
getStyle()
Get the text style of the annotation. |
void |
putRichTextResource(String key,
Object value)
Add a resource that is referenced by the rich content set in setRichTextContents(java.lang.String) . |
void |
setBackgroundStyle(PDFStyle style)
Set the background style for the annotation. |
void |
setCallout(float[] cl)
Set the "Callout" for this box. |
void |
setCalloutEnding(String type)
Set the type of Line-Ending that's used to mark the end of a callout - an arrow, circle or similar. |
void |
setColor(Color color)
Set the background color of the annotation. |
void |
setContentRectangle(float x1,
float y1,
float x2,
float y2)
Set the rectangle of the content of this annotation. |
void |
setContents(String content)
Set the contents of the annotation. |
void |
setRichTextContents(String content)
Set the Rich-text contents of the annotation. |
void |
setStyle(PDFStyle style)
Set the style to display the text in |
String |
toString()
|
Methods inherited from class org.faceless.pdf2.PDFAnnotation |
---|
addPropertyChangeListener, addReview, flatten, getAuthor, getContents, getCreationDate, getInReplyTo, getMetaData, getModifyDate, getOpacity, getPage, getPopup, getRectangle, getReplies, getReviews, getSubject, getType, getUniqueID, hasAppearanceState, isContentLocked, isPositionLocked, isPrintable, isReadOnly, isVisible, removePropertyChangeListener, setAuthor, setCreationDate, setInReplyTo, setLocked, setMetaData, setModifyDate, setOpacity, setPage, setPrintable, setReadOnly, setRectangle, setSubject, setUniqueID, setVisible |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public AnnotationText()
Method Detail |
---|
public void setContents(String content)
rich-text Content
, this method will overwrite it.
setContents
in class PDFAnnotation
content
- the content of the Text annotation. May contain "\n" characters
to indicate newlinespublic void setRichTextContents(String content)
tags
which contain zero or more , and tags. The only permitted attribute
is "style". An example would be:
<?xml version="1.0"?>
<body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:APIVersion="Acrobat:9.0.0" xfa:spec="2.0.2" style="font-size:14pt;text-align:left;color:#000000;font-weight:normal;font-style:normal;font-family:Helvetica,sans-serif">
<p>
<span>This text is <i>italic</i> and this is in <span style="color:#FF0000">red </span>
</p>
<p>
<span>This is the next line of text</span>
</p>
</body>
Note that due to quirks in Acrobat, newlines in the text should be indicated with a
"&#13;" character as well as with a paragraph end. Failing to do so will lose the
rich-text formatting if the field is subsequently edited in Acrobat.
Calling this method will also update the plain-text version of the Content, as returned
by PDFAnnotation.getContents()
.
content
- a Rich Text String
IllegalArgumentException
- if the supplied content is not well formed XHTML.setContents(java.lang.String)
,
PDFAnnotation.getContents()
,
getRichTextContents()
public void putRichTextResource(String key, Object value)
setRichTextContents(java.lang.String)
.
For example, if the rich content included a <span style='font-family:MyFont'>
you would need to make the MyFont
font available to the annotation by doing
putRichTextResource("MyFont", font)
, where font
is a PDFFont
.
- Parameters:
key
- the name of the resourcevalue
- the resources - any object, but typically a PDFFont
or null to
remove a previously set value.- Since:
- 2.11.25
public String getRichTextContents()
null
if only
plain-text content is available
public void setStyle(PDFStyle style)
style
- the style to display the text inpublic void setBackgroundStyle(PDFStyle style)
public PDFStyle getStyle()
public PDFStyle getBackgroundStyle()
public Color getColor()
getBackgroundStyle().getFillColor()
getColor
in class PDFAnnotation
public void setColor(Color color)
setColor
in class PDFAnnotation
public void setCallout(float[] cl)
Set the "Callout" for this box. Since Acrobat 7.0 a Text annotation
may have a "callout arrow" which is drawn in one or two segments from
the box itself. The paramater "cl" is an array of 4 or 6 floats - the
first two parameters are the point the callout points to, the last
two parameters are the point the line joins onto the box, and if the
array is 6 items long, the middle two points are the "elbow" of the line.
A value of null
removes the callout line.
As an example, if the rectangle of the box is (100, 100, 200, 200), a callout could be specified as (0, 0, 0, 150, 100, 150) to draw a line from the bottom-left of the page up the left hand side, and then across to join the box in the middle.
If the first point of the callout is inside the box itself, an
IllegalArgumentException
is thrown. Otherwise the points will be
adjusted if necessary to join onto the box in a sensible manner.
cl
- the callout points - either an array of 4 points as (x1, y1, x2, y2),
or an array of 6 points as (x1, y1, x2, y2, x3, y3)public void setCalloutEnding(String type)
AnnotationShape
class.
Since 2.11.7
public String getCalloutEnding()
setCalloutEnding(java.lang.String)
public float[] getCallout()
setCallout(float[])
public float[] getContentRectangle()
PDFAnnotation.getRectangle()
public void setContentRectangle(float x1, float y1, float x2, float y2)
PDFAnnotation.setRectangle(float, float, float, float)
public String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |