Package org.faceless.pdf2
Class AnnotationStamp
- java.lang.Object
-
- org.faceless.pdf2.PDFAnnotation
-
- org.faceless.pdf2.AnnotationStamp
-
- All Implemented Interfaces:
java.lang.Cloneable
public final class AnnotationStamp extends PDFAnnotation
A "Rubber-Stamp" annotation, which can also contain a longer message in an associated pop-up window. A number of predefined rubber stamps exist, or for custom stamps they can be created from aPDFCanvas
object. For example, to add a rubber stamp to page, try something like this:AnnotationStamp stamp = new AnnotationStamp("stamp.standard.Approved", 1); float x = page.getWidth()/2; float y = page.getHeight()/2; float w = stamp.getRecommendedWidth(); float h = stamp.getRecommendedHeight(); stamp.setRectangle(x-(w/2), y-(h/2), x+(w/2), y+(h/2)); page.addAnnotation(stamp);
- Since:
- 2.0
-
-
Constructor Summary
Constructors Constructor Description AnnotationStamp()
Create a new, uninitialized AnnotationStamp object.AnnotationStamp(java.lang.String type, float opacity)
Create a rubber-stamp annotation which can be added to the page.AnnotationStamp(java.lang.String name, PDFCanvas canvas)
Create a new Stamp from the specified canvas.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.Object
clone()
float
getRecommendedHeight()
Return the recommended height of this stampfloat
getRecommendedWidth()
Return the recommended width of this stampint
getRotate()
Get the rotation of this stamp, as set bysetRotate(int)
java.lang.String
getType()
Returns the type of Stamp used.void
putLiteral(java.lang.String key, java.lang.String tokens)
Put a literal token sequnce.void
rebuild()
Rebuild the annotation's appearance.void
setBlendMode(java.lang.String mode)
Set the "Blend Mode" of this stamp.void
setCanvas(java.lang.String name, PDFCanvas canvas)
Set this stamp to use the specified canvasvoid
setRotate(int rotate)
Set the rotation of the specified Stamp.void
setType(java.lang.String type, float opacity)
Set the type of the stamp to one of the predefined "standard" types available with Acrobat.java.lang.String
toString()
-
Methods inherited from class org.faceless.pdf2.PDFAnnotation
addPropertyChangeListener, addReview, flatten, getAction, getAssociatedFiles, getAuthor, getColor, getContents, getCreationDate, getDefaultColorSpace, getInReplyTo, getLocale, getMetaData, getModifyDate, getOpacity, getOptionalContentDescriptor, getPage, getPopup, getRectangle, getReplies, getReviews, getSubject, getUniqueID, getUserData, getXMP, hasAppearanceState, isContentLocked, isPositionLocked, isPrintable, isReadOnly, isVisible, putUserData, removePropertyChangeListener, setAction, setAuthor, setColor, setContents, setCreationDate, setDefaultColorSpace, setInReplyTo, setLocale, setLocked, setMetaData, setModifyDate, setOpacity, setOptionalContentDescriptor, setPage, setPrintable, setReadOnly, setRectangle, setSubject, setUniqueID, setVisible
-
-
-
-
Constructor Detail
-
AnnotationStamp
public AnnotationStamp()
Create a new, uninitialized AnnotationStamp object. ThesetType()
orsetCanvas()
method must be called on this stamp to initialize it;- Since:
- 2.11.6
-
AnnotationStamp
public AnnotationStamp(java.lang.String type, float opacity)
Create a rubber-stamp annotation which can be added to the page. Calls thesetType()
method - see that method's API docs for details- Parameters:
type
- the type of stampopacity
- the opacity of the stamp - anywhere between 0 (for transparent) and 1 (for opaque).- Throws:
java.lang.IllegalArgumentException
- if the stamp type is unknown- Since:
- 2.0
- See Also:
setType(java.lang.String, float)
-
AnnotationStamp
public AnnotationStamp(java.lang.String name, PDFCanvas canvas)
Create a new Stamp from the specified canvas. Calls thesetCanvas()
method - see that method's API docs for details- Parameters:
name
- the name of the stampcanvas
- the canvas to use as the body of the stamp- Since:
- 2.0
- See Also:
setCanvas(java.lang.String, org.faceless.pdf2.PDFCanvas)
-
-
Method Detail
-
setType
public void setType(java.lang.String type, float opacity)
Set the type of the stamp to one of the predefined "standard" types available with Acrobat. The available types are:stamp.stencil.Approved The word "Approved" in a rubber-stamp style stamp.stencil.AsIs The words "As Is" in a rubber-stamp style stamp.stencil.Confidential The word "Confidential" in a rubber-stamp style stamp.stencil.Departmental The word "Departmental" in a rubber-stamp style stamp.stencil.Draft The word "Draft" in a rubber-stamp style stamp.stencil.Experimental The word "Experimental" in a rubber-stamp style stamp.stencil.Expired The word "Expired" in a rubber-stamp style stamp.stencil.Final The word "Final" in a rubber-stamp style stamp.stencil.ForComment The words "For Comment" in a rubber-stamp style stamp.stencil.ForPublicRelease The words "For Public Release" in a rubber-stamp style stamp.stencil.NotApproved The words "Not Approved" in a rubber-stamp style stamp.stencil.NotForPublicRelease The words "Not For Public Release" in a rubber-stamp style stamp.stencil.Sold The words "As Is" in a rubber-stamp style stamp.stencil.TopSecret The words "Top Secret" in a rubber-stamp style stamp.standard.Approved The word "Approved" inside a box stamp.standard.Completed The word "Completed" inside a box stamp.standard.Confidential The word "Confidential" inside a box stamp.standard.Draft The word "Draft" inside a box stamp.standard.Final The word "Final" inside a box stamp.standard.ForComment The words "For Comment" inside a box stamp.standard.ForPublicRelease The words "For Public Release" inside a box stamp.standard.InformationOnly The words "Information Only" inside a box stamp.standard.NotApproved The words "Not Approved" inside a box stamp.standard.NotForPublicRelease The words "Not For Public Release" inside a box stamp.standard.PreliminaryResults The words "Preliminary Results" inside a box stamp.standard.Void The word "Void" inside a box stamp.signhere.Accepted A green tick stamp.signhere.Rejected A red cross stamp.signhere.InitialHere An arrow with the words "Initial Here" stamp.signhere.SignHere An arrow with the words "Sign Here" stamp.signhere.Witness An arrow with the words "Witness" - Parameters:
type
- the type of stamp - one of the values listed aboveopacity
- the opacity of the stamp - anywhere between 0 (for transparent) and 1 (for opaque). Note that transparency was only added in Acrobat 5, so earlier viewers will ignore this setting.- Throws:
java.lang.IllegalArgumentException
- if the stamp type is unknown- Since:
- 2.11.6
-
rebuild
public void rebuild()
Description copied from class:PDFAnnotation
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.- Overrides:
rebuild
in classPDFAnnotation
-
setCanvas
public void setCanvas(java.lang.String name, PDFCanvas canvas)
Set this stamp to use the specified canvas- Parameters:
name
- the name of the stampcanvas
- the canvas to use as the body of the stamp- Since:
- 2.11.6
-
getRotate
public int getRotate()
Get the rotation of this stamp, as set bysetRotate(int)
- Since:
- 2.11.7
-
setRotate
public void setRotate(int rotate)
Set the rotation of the specified Stamp. We recommend the page and rectangle of the stamp are set before this method is called. Rotating an already rotated stamp will give the same broken results that you get in Acrobat, due to a specification fault.- Parameters:
rotate
- the rotation in degrees clockwise;- Since:
- 2.11.7
-
getType
public java.lang.String getType()
Returns the type of Stamp used. This will probably be a textual description of the contents of the stamp, but is not guaranteed to be.- Overrides:
getType
in classPDFAnnotation
-
getRecommendedWidth
public float getRecommendedWidth()
Return the recommended width of this stamp
-
getRecommendedHeight
public float getRecommendedHeight()
Return the recommended height of this stamp
-
setBlendMode
public void setBlendMode(java.lang.String mode)
Set the "Blend Mode" of this stamp.- Since:
- 2.11.8
- See Also:
PDFStyle.setBlendMode(java.lang.String)
-
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
-
-