Class PDFAnnotation
- java.lang.Object
-
- org.faceless.pdf2.PDFAnnotation
-
- All Implemented Interfaces:
java.lang.Cloneable
- Direct Known Subclasses:
AnnotationFile
,AnnotationLink
,AnnotationMarkup
,AnnotationNote
,AnnotationRichMedia
,AnnotationShape
,AnnotationSound
,AnnotationStamp
,AnnotationText
,WidgetAnnotation
public class PDFAnnotation extends java.lang.Object
A PDFAnnotation allows the user to interact with the generated PDF document, by adding / viewing rubber-stamps, popup notes hyperlinks and so on. A special subclass of annotation, called a Widget, is also used to display
FormElement
objects on the page. Since version 2.0, the various types of annotation have been split into unique subclasses. This class contains the methods that are common to all of them.- Since:
- 1.1
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPropertyChangeListener(java.beans.PropertyChangeListener l)
Add a PropertyChangeListener to this PDFAnnotation.AnnotationNote
addReview(java.lang.String name, java.lang.String status)
Add a review to this annotation.protected java.lang.Object
clone()
void
flatten()
Stamp the visible appearance of this annotation permanently onto its page, and remove the annotation from the page.PDFAction
getAction(Event event)
Return the action assocaited with this event, as set bysetAction(org.faceless.pdf2.Event, org.faceless.pdf2.PDFAction)
, or null if its unset.java.util.Collection<EmbeddedFile>
getAssociatedFiles()
Return the list of embedded files assocatiated with this PDFAnnotation.java.lang.String
getAuthor()
Return the author (or "Label") of the annotation if set, as set bysetAuthor(java.lang.String)
Note prior to version 2.3.7 this method existed, but only on certain subclasses.java.awt.Color
getColor()
java.lang.String
getContents()
Return the value of the "Contents" property of this annotation, as set bysetContents(java.lang.String)
.java.util.Calendar
getCreationDate()
Return the date when the annotation was first created if specified, ornull
otherwise.java.awt.color.ColorSpace
getDefaultColorSpace(int components)
Return the ColorSpace used by this annotation to anchor device-dependent colors to a profile.PDFAnnotation
getInReplyTo()
Return the PDFAnnotation that this annotation is in reply to, ornull
if this annotation is not in reply to anything.java.util.Locale
getLocale()
Get the Locale on this annotation, as set bysetLocale(java.util.Locale)
.java.io.Reader
getMetaData()
Return any XML metadata associated with this object.java.util.Calendar
getModifyDate()
Return the date when the annotation was last modified if specified, ornull
otherwise.int
getOpacity()
Return the opacity of this annotation, as set bysetOpacity(int)
OptionalContentDescriptor
getOptionalContentDescriptor()
Return the OptionalContentDescriptor previously set bysetOptionalContentDescriptor(org.faceless.pdf2.OptionalContentDescriptor)
PDFPage
getPage()
Return the page that this annotation is on, ornull
if it a new annotation which has not yet been placed on a pagePDFAnnotation
getPopup()
Return the Popup annotation for this annotation.float[]
getRectangle()
Return the rectangle this annotation applies to on the page, or null if no rectangle applies for this type of annotation.java.util.List<PDFAnnotation>
getReplies()
Get an unmodifiable List ofPDFAnnotation
objects that are in reply to this Annotation.java.util.List<PDFAnnotation>
getReviews()
Get an unmodifiable List ofPDFAnnotation
objects that are reviews of this Annotation.java.lang.String
getSubject()
Get the subject of the annotation, as set bysetSubject(java.lang.String)
java.lang.String
getType()
Return the type of annotation.java.lang.String
getUniqueID()
Return the unique ID for this annotation, if set.java.lang.Object
getUserData(java.lang.String key)
Return a property previously set on the PDF with theputUserData()
methodXMP
getXMP()
Return an XMP Metadata object representing any XML metadata associated with this objectboolean
hasAppearanceState(java.lang.String state)
Return true if this annotation has an appearance for the specified state.boolean
isContentLocked()
Returns whether the content of the annotation is lockedboolean
isPositionLocked()
Returns whether the size and position of the annotation is lockedboolean
isPrintable()
Returns whether the annotation is included when the document is printed (true) or not (false)boolean
isReadOnly()
Return whether the annotation to "read-only".boolean
isVisible()
Returns whether the annotation is visible on the screen (true) or not (false)void
putLiteral(java.lang.String key, java.lang.String tokens)
Put a literal token sequnce.void
putUserData(java.lang.String key, java.lang.Object value)
Set a custom property on the PDF.void
rebuild()
Rebuild the annotation's appearance.void
removePropertyChangeListener(java.beans.PropertyChangeListener l)
Remove a previously added PropertyChangeListener from this PDFAnnotation.void
setAction(Event event, PDFAction action)
Set an action to occur when the specified event happens to this annotation.void
setAuthor(java.lang.String label)
Set the author of the annotation.void
setColor(java.awt.Color color)
Set theColor
of the annotation.void
setContents(java.lang.String contents)
Set the "Contents" value of this annotation, which is required for "note" annotations and when making annotations accessible.void
setCreationDate(java.util.Calendar date)
Set the date when the annotation was created.void
setDefaultColorSpace(int components, java.awt.color.ColorSpace cs)
Set the ColorSpace to use to anchor device-dependent colors on this annotation, as described bygetColorSpace(java.lang.String)
.void
setInReplyTo(PDFAnnotation annotation)
Set which annotation this annotation is in reply to.void
setLocale(java.util.Locale locale)
Set the Locale on this annotation.void
setLocked(boolean position, boolean content)
Set the annotation to be "locked".void
setMetaData(java.lang.String metadata)
Set the XML metadata associated with this object.void
setModifyDate(java.util.Calendar date)
Set the date when the annotation is last modified.void
setOpacity(int opacity)
Set the opacity of this annotation.void
setOptionalContentDescriptor(OptionalContentDescriptor descriptor)
Set the optional content descriptor that this annotation belongs to.void
setPage(PDFPage page)
Set the page for this annotation.void
setPrintable(boolean printable)
Set whether the annotation is included when the document is printed.void
setReadOnly(boolean readonly)
Set the annotation to "read-only", or not.void
setRectangle(float x1, float y1, float x2, float y2)
Set the rectangle for the annotation - where it is on the page.void
setSubject(java.lang.String subject)
Set the subject of the annotation.void
setUniqueID(java.lang.String id)
Set the unique ID for this annotation.void
setVisible(boolean visible)
Set whether the annotation is visible on screen.java.lang.String
toString()
-
-
-
Method Detail
-
getType
public java.lang.String getType()
Return the type of annotation. Could be one of "Text" (forAnnotationNote
s), "Link", (forAnnotationLink
s), "Stamp" (forAnnotationStamp
s), "Widget" (forWidgetAnnotation
s), "Highlight", "Underline", "Squiggly" or "StrikeOut" (forAnnotationMarkup
s), "FreeText" (forAnnotationText
s), "FileAttachment" (forAnnotationFile
s) or "Line", "Square", "Circle", "Polygon", "Polyline", "Caret", "Ink", "Popup", "Sound", "Movie", "Screen", "PrinterMark" or "TrapNet", all of which only have only basic support with this API.- Since:
- 1.1.12
-
setRectangle
public void setRectangle(float x1, float y1, float x2, float y2)
Set the rectangle for the annotation - where it is on the page. Every annotation must have a rectangle set - if it's not set when the document is written, it's forced to (0,0,0,0).- For
AnnotationLink
andAnnotationStamp
annotations, this is the rectangle containing the hyperlink area or stamp. - For
AnnotationNote
annotations, whether this method adjusts the location of the icon or the popup window depends on whether the annotation is closed or open at the time of the call to this method. When closed, the icon is positioned at x1,y2
Note that all co-ordinates are in absolute page co-ordinates. This means they are measured in points from the bottom-left hand corner of the page, regardless of any calls to
PDFPage.rotate(float, float, double)
orPDFPage.setUnits(float, int)
that have been made. This restriction is part of the PDF specification.- Parameters:
x1
- the X co-ordinate of the bottom-left corner of the rectangley1
- the Y co-ordinate of the bottom-left corner of the rectanglex2
- the X co-ordinate of the top-right corner of the rectangley2
- the Y co-ordinate of the top-right corner of the rectangle
- For
-
getPopup
public PDFAnnotation getPopup()
Return the Popup annotation for this annotation.- Since:
- 2.8
-
getRectangle
public float[] getRectangle()
Return the rectangle this annotation applies to on the page, or null if no rectangle applies for this type of annotation. See thesetRectangle()
method for a discussion on units.- Returns:
- the rectangle for this annotation, in the form of an array (x1, y1, x2, y2)
- Since:
- 1.1.12
- See Also:
setRectangle(float, float, float, float)
-
hasAppearanceState
public boolean hasAppearanceState(java.lang.String state)
Return true if this annotation has an appearance for the specified state.- Parameters:
state
- the state to check - "N" for normal, "D" for down or "R" for rollover- Since:
- 2.10.3
-
getPage
public PDFPage getPage()
Return the page that this annotation is on, ornull
if it a new annotation which has not yet been placed on a page- Since:
- 1.1.23
-
setPage
public void setPage(PDFPage page)
Set the page for this annotation. This is useful when moving annotations between documents or across pages - when simply adding a new annotation to a page, this method is identical to callingPDFPage.getAnnotations()
.add()
- Since:
- 1.1.23
-
setVisible
public void setVisible(boolean visible)
Set whether the annotation is visible on screen. By default, all new annotations are visible.- Parameters:
visible
- whether the annotation should be displayed on the screen- Since:
- 1.1.23
-
setPrintable
public void setPrintable(boolean printable)
Set whether the annotation is included when the document is printed. By default, all new annotations (except for hyperlinks) are printed.- Parameters:
printable
- whether the annotation should be printed- Since:
- 1.1.23
-
setReadOnly
public void setReadOnly(boolean readonly)
Set the annotation to "read-only", or not. Read-only annotations cannot be moved or deleted and do not respond to mouse clicks in Acrobat
Additionally, using Acrobat there is no way to change this flag, so fields set to read-only using this method will basically stay that way unless edited with an API like this one. This makes this setting useful for placing "permanent" annotations on a page.
Note this value is ignored for
WidgetAnnotation
objects - see theFormElement.setReadOnly(boolean)
method instead- Since:
- 2.0
-
isVisible
public boolean isVisible()
Returns whether the annotation is visible on the screen (true) or not (false)- Since:
- 1.1.23
-
isPrintable
public boolean isPrintable()
Returns whether the annotation is included when the document is printed (true) or not (false)- Since:
- 1.1.23
-
isReadOnly
public boolean isReadOnly()
Return whether the annotation to "read-only". Read-only annotations cannot be moved or deleted and do not respond to mouse clicks in Acrobat.
Note this value is ignored for
WidgetAnnotation
objects - see theFormElement.isReadOnly()
method instead.- Since:
- 2.0
- See Also:
setReadOnly(boolean)
,FormElement.isReadOnly()
-
setLocked
public void setLocked(boolean position, boolean content)
Set the annotation to be "locked". It's possible to lock the size and position of the annotation, the content, or both - although locking the content is only supported in Acrobat 8 or later
- Parameters:
position
- whether to lock the size/position of the annotationcontent
- whether to lock the content of the annotation- Since:
- 2.11.4
-
isPositionLocked
public boolean isPositionLocked()
Returns whether the size and position of the annotation is locked- Since:
- 2.11.4
-
isContentLocked
public boolean isContentLocked()
Returns whether the content of the annotation is locked- Since:
- 2.11.4
-
setMetaData
public void setMetaData(java.lang.String metadata)
Set the XML metadata associated with this object. Since 2.26 this method callsgetXMP().read(new StringReader(xmldata == null ? "" : xmldata))
. We strongly recommend using thegetXMP()
method and modifying the XMP directly rather than using this method.- Parameters:
metadata
- the XML data to embed into the document, or null to clear any existing metadata. No validation is performed on this input.- Since:
- 2.11.5
- See Also:
getXMP()
-
getMetaData
public java.io.Reader getMetaData() throws java.io.IOException
Return any XML metadata associated with this object.
Since 2.26 this simply returns
getXMP().isEmpty() ? null : new StringReader(getXMP().toString())
. It is strongly recommended that any code migrates to using thegetXMP()
method.Since 2.24.3, the returned type is guaranteed to hava a
toString()
method that will return the Metadata as a String.- Returns:
- a
Reader
containing the source of the XML or null if no metadata is available. - Throws:
java.io.IOException
- if the metadata can't be extracted- Since:
- 2.11.5
-
getXMP
public XMP getXMP()
Return an XMP Metadata object representing any XML metadata associated with this object- Returns:
- the XMP, which may be empty or invalid but will never be null
- Since:
- 2.26
-
getModifyDate
public java.util.Calendar getModifyDate()
Return the date when the annotation was last modified if specified, ornull
otherwise.- Since:
- 2.0 - prior to that this method was called
getLastModified
-
setModifyDate
public void setModifyDate(java.util.Calendar date)
Set the date when the annotation is last modified. This is updated automatically when the annotation is modified, so there's no need to call this unless you need to set it to a specific value.- Parameters:
date
- the Date to set the modification date to- Since:
- 2.7.1
-
getCreationDate
public java.util.Calendar getCreationDate()
Return the date when the annotation was first created if specified, ornull
otherwise.- Since:
- 2.0
-
setCreationDate
public void setCreationDate(java.util.Calendar date)
Set the date when the annotation was created. This is set automatically when an annotation is created, so there's no need to call this method unless you need to set it to a specific value.- Parameters:
date
- the Date to set the creation date to- Since:
- 2.7.1
-
setSubject
public void setSubject(java.lang.String subject)
Set the subject of the annotation. This is an Acrobat 6.0 feature only, but will safely be ignored by earlier viewers. For some annotations (includingAnnotationLink
andWidgetAnnotation
) this has no effect- Parameters:
subject
- a brief summary of the contents of the annotation- Since:
- 2.0
-
getSubject
public java.lang.String getSubject()
Get the subject of the annotation, as set bysetSubject(java.lang.String)
- Since:
- 2.0
-
setInReplyTo
public void setInReplyTo(PDFAnnotation annotation)
Set which annotation this annotation is in reply to. This is an Acrobat 6 or later only feature, although it will safely be ignored by earlier viewers. The two annotations must be on the same page to be related like this - if they're not, this annotation will be moved to the page of it's reply. For some annotations (includingAnnotationLink
andWidgetAnnotation
) this has no effect- Parameters:
annotation
- the annotation this is in reply to, ornull
to remove the current value- Since:
- 2.0
-
getInReplyTo
public PDFAnnotation getInReplyTo()
Return the PDFAnnotation that this annotation is in reply to, ornull
if this annotation is not in reply to anything.- Since:
- 2.0
-
setUniqueID
public void setUniqueID(java.lang.String id)
Set the unique ID for this annotation. See thegetUniqueID()
method for more information. Note that it is down to the user to ensure that the unique ID generated is actually unique. Since 2.3.7 all new annotations have a random unique ID generated when created.- Parameters:
id
- the unique ID to assign to this annotation- Since:
- 2.0.8
-
getUniqueID
public java.lang.String getUniqueID()
Return the unique ID for this annotation, if set. This is the "NM" field, added as an optional attribute in Acrobat 5.0, and is usually in the form of a 15-30 random characters. If no unique ID is set, this method returns null.- Since:
- 2.0.8
-
setAuthor
public void setAuthor(java.lang.String label)
Set the author of the annotation. This is also sometimes referred to as the Label. Note prior to version 2.3.7 this method existed, but only on certain subclasses. For some annotations (includingAnnotationLink
andWidgetAnnotation
) this has no effect- Since:
- 2.3.7
-
getAuthor
public java.lang.String getAuthor()
Return the author (or "Label") of the annotation if set, as set bysetAuthor(java.lang.String)
Note prior to version 2.3.7 this method existed, but only on certain subclasses.- Since:
- 2.3.7
-
setContents
public void setContents(java.lang.String contents)
Set the "Contents" value of this annotation, which is required for "note" annotations and when making annotations accessible. For note annotations, this is the contents of the pop-up window displayed when the annotation is open.- Parameters:
contents
- the contents of the window - may contain newline and non-ASCII Unicode characters.- Since:
- 2.3.7
-
getContents
public java.lang.String getContents()
Return the value of the "Contents" property of this annotation, as set bysetContents(java.lang.String)
.- Since:
- 2.3.7
-
setColor
public void setColor(java.awt.Color color)
Set theColor
of the annotation. This color will be used for the following purposes:- The background of the annotation's icon when closed, if applicable
- The title bar of the annotation's pop-up window
- The border of a link annotation
- Since:
- 2.3.7
-
getColor
public java.awt.Color getColor()
- Since:
- 2.3.7
-
setOpacity
public void setOpacity(int opacity)
Set the opacity of this annotation. A value of 100 (the default) means the annotation is completely opaque, a value of 0 means completely invisible. For some annotations (includingAnnotationLink
andWidgetAnnotation
) this has no effect Note this setting will be ignored by Acrobat 4.0 and earlier.- Parameters:
opacity
- the opacity of the annotation from 0 to 100- Since:
- 2.3.7
-
rebuild
public void rebuild()
Rebuild the annotation's appearance. This will be done automatically when required, usually just before saving the PDF or rasterizing it to a bitmap. However this method can be called explicitly if necessary, usually to ensure the rebuild (which may fire aPropertyChangeEvent
) is run on a specific thread.- Since:
- 2.11.26
-
getOpacity
public int getOpacity()
Return the opacity of this annotation, as set bysetOpacity(int)
- Returns:
- the opacity of the annotation
- Since:
- 2.3.7
-
addReview
public AnnotationNote addReview(java.lang.String name, java.lang.String status)
Add a review to this annotation. See thegetReviews()
method for a more complete discussion of annotation reviews. This method is a convenient way of creating a newAnnotationNote
, setting it'sstatus
andauthor
, and marking it as in reply to this annotation. For some annotations (includingAnnotationLink
andWidgetAnnotation
), this method will have no effect and will return null- Parameters:
name
- the name of the person doing the reviewstatus
- the status of the review - must be one of those listed for theAnnotationNote.setStatus(java.lang.String)
method, or anIllegalArgumentException
is thrown.- Returns:
- the AnnotationNote that was created, or
null
if none was created - Since:
- 2.4
-
getReplies
public java.util.List<PDFAnnotation> getReplies()
Get an unmodifiable List of
PDFAnnotation
objects that are in reply to this Annotation.Since Acrobat 6.0 it has been possible to add "replies" to another annotation. These replies are actually
PDFAnnotation
objects - although the specification allows for any type of annotation to be used as a reply, in general onlyAnnotationNote
objects are used. These annotations have the same physical location as the original one, but return a value fromgetInReplyTo()
. Unlike those returned bygetReviews()
, they have aAnnotationNote.getStatus()
equal tonull
.The list returned by this method is a convenient way of doing the following: Loop over all annotations on the same page as this one, and return any
PDFAnnotation
objects in reply to this one that haveAnnotationNote.getStatus()
equal tonull
.Note the returned list is unmodifiable - if you want to remove a reply, delete it from it's pages list of annotations.
- Returns:
- an unmodifiable List containing all the replies to this annotation
- Since:
- 2.4
- See Also:
getReplies()
,setInReplyTo(org.faceless.pdf2.PDFAnnotation)
-
getReviews
public java.util.List<PDFAnnotation> getReviews()
Get an unmodifiable List of
PDFAnnotation
objects that are reviews of this Annotation.Since Acrobat 6.0 it has been possible to "review" another annotation by setting it's status to "Accepted", "Rejected", "Cancelled" or "Completed". It's also possible to "Mark" or "Unmark" an annotation (in Acrobat, this appears as a checkbox next to the annotation)
These "reviews" are actually a collection of
PDFAnnotation
objects which are attached to the original annotation, very similar to the Replies as returned bygetReplies()
. The only different is that they have a "State" set, which you can see using theAnnotationNote.getStatus()
method.The list returned from this method is a convenient way of doing the following: Loop over all annotations on the same page as this one, and return any
PDFAnnotation
objects in reply to this one, or one of it's other reviews, that haveAnnotationNote.getStatus()
set to a non-null value.- Returns:
- an unmodifiable List containing all the Reviews of this annotation
- Since:
- 2.4
- See Also:
getReplies()
,setInReplyTo(org.faceless.pdf2.PDFAnnotation)
,addReview(java.lang.String, java.lang.String)
,AnnotationNote.getStatus()
-
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Add a PropertyChangeListener to this PDFAnnotation. PropertyChangeEvents will be raised when various aspects of this annotation are changed
-
removePropertyChangeListener
public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Remove a previously added PropertyChangeListener from this PDFAnnotation.- Since:
- 2.10.4
- See Also:
removePropertyChangeListener(java.beans.PropertyChangeListener)
-
flatten
public void flatten()
Stamp the visible appearance of this annotation permanently onto its page, and remove the annotation from the page. The annotation object should be discarded afterwards.
Note that this method removes this PDFAnnotation from the page list (and if this annotation is a Widget, from the
FormElement.getAnnotations()
FormElement Annotations list} as well), which could result in aConcurrentModificationException
if you wereiterating
over the page's annotations. To flatten all the annotations on a page we'd recommend something like this:List<PDFAnnotation> l = page.getAnnotations(); while (!l.isEmpty()) { l.get(l.size() - 1).flatten(); }
- Since:
- 2.11.19
- See Also:
FormElement.flatten()
,Form.flatten()
-
setLocale
public void setLocale(java.util.Locale locale)
Set the Locale on this annotation. The locale property (really the Language property, but Locale is consistant with PDF#setLocale) on a PDFAnnotation is new in PDF 2.0- Since:
- 2.24.2
-
getLocale
public java.util.Locale getLocale()
Get the Locale on this annotation, as set bysetLocale(java.util.Locale)
. The ability for an annotation to have a Locale is new in PDF 2.0- Returns:
- the annotation locale, or PDF.LOCALEROOT if none is set
- Since:
- 2.24.2
-
setOptionalContentDescriptor
public void setOptionalContentDescriptor(OptionalContentDescriptor descriptor)
Set the optional content descriptor that this annotation belongs to. If not null, the annotation will only be considered visible if the descriptor is visible- Since:
- 2.24.2
- See Also:
PDFCanvas.setOptionalContentDescriptor(org.faceless.pdf2.OptionalContentDescriptor)
-
getOptionalContentDescriptor
public OptionalContentDescriptor getOptionalContentDescriptor()
Return the OptionalContentDescriptor previously set bysetOptionalContentDescriptor(org.faceless.pdf2.OptionalContentDescriptor)
- Since:
- 2.24.2
-
getAssociatedFiles
public java.util.Collection<EmbeddedFile> getAssociatedFiles()
Return the list of embedded files assocatiated with this PDFAnnotation. The list is live and can be edited. Note that prior to 2.26, this method returned a List rather than a Collection. It was changed to match the same methods onOutputProfile.getAssociatedFiles()
andPDFPage.getAssociatedFiles()
. The ability to associate files with a PDFAnnotation is new in PDF 2.0.- Since:
- 2.24.2
- See Also:
AnnotationFile
-
getAction
public PDFAction getAction(Event event)
Return the action assocaited with this event, as set bysetAction(org.faceless.pdf2.Event, org.faceless.pdf2.PDFAction)
, or null if its unset.- Parameters:
event
- the event- Since:
- 2.24.3
-
setAction
public void setAction(Event event, PDFAction action)
Set an action to occur when the specified event happens to this annotation.
The event can be one of
Event.MOUSEOVER
,Event.MOUSEOUT
,Event.MOUSEDOWN
,Event.MOUSEUP
,Event.FOCUS
,Event.BLUR
,Event.SHOW
,Event.HIDE
,Event.OPEN
orEvent.CLOSE
- Parameters:
event
- the event the action applies toaction
- the action you wish to occur, ornull
to remove the action- Throws:
java.lang.IllegalArgumentException
- if the event is invalid.- Since:
- 2.24.3
-
putUserData
public void putUserData(java.lang.String key, java.lang.Object value)
Set a custom property on the PDF. The property will be saved with the file with the "BFOO_" prefix.- Parameters:
value
- a CharSequence, Number, Date, Calendar, Boolean, byte[], or a List/Map of those values, or null to remove the property- Since:
- 2.24.2
-
getUserData
public java.lang.Object getUserData(java.lang.String key)
Return a property previously set on the PDF with theputUserData()
method- Returns:
- a String, Boolean, Number, Calendar, byte[] or a Map/List of those values if found, or null if no such property exists.
- Since:
- 2.24.2
-
getDefaultColorSpace
public java.awt.color.ColorSpace getDefaultColorSpace(int components)
Return the ColorSpace used by this annotation to anchor device-dependent colors to a profile. For example, the ColorSpace returned by
getDefaultColorSpace(3)
is used by all "Device RGB" colors on the annotation, effectively turning them into calibrated colors.Annotations do not inherit any default ColorSpace set on the page.
- Parameters:
components
- identifies the Default ColorSpace we're requesting - valid values are 1 for Gray, 3 for RGB or 4 for CMYK.- Returns:
- the Default ColorSpace requested, or null if none is set.
- Since:
- 2.26.1
- See Also:
PDFPage.getDefaultColorSpace(int)
-
setDefaultColorSpace
public void setDefaultColorSpace(int components, java.awt.color.ColorSpace cs)
Set the ColorSpace to use to anchor device-dependent colors on this annotation, as described bygetColorSpace(java.lang.String)
.- Parameters:
components
- identifies the Default ColorSpace to set - valid values are 1 for Gray, 3 for RGB or 4 for CMYK.cs
- the ColorSpace to set, which must be either null (to delete the existing value) or a ColorSpace of a type that matches the "components" parameter.- Since:
- 2.26.1
-
toString
public java.lang.String toString()
-
putLiteral
public void putLiteral(java.lang.String key, java.lang.String tokens)
Put a literal token sequnce. For debugging- Parameters:
key
- the keytokens
- the token sequence, eg "true" or "/foo" or "[/Foo/Bar]". No refs, just direct objects.
-
clone
protected java.lang.Object clone()
- Overrides:
clone
in classjava.lang.Object
-
-