Method from org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation Detail: |
public static PDAnnotation createAnnotation(COSBase base) throws IOException {
PDAnnotation annot = null;
if( base instanceof COSDictionary )
{
COSDictionary annotDic = (COSDictionary)base;
String subtype = annotDic.getNameAsString( COSName.SUBTYPE );
if( subtype.equals( PDAnnotationFileAttachment.SUB_TYPE ) )
{
annot = new PDAnnotationFileAttachment( annotDic );
}
else if( subtype.equals( PDAnnotationLine.SUB_TYPE ) )
{
annot = new PDAnnotationLine( annotDic );
}
else if( subtype.equals( PDAnnotationLink.SUB_TYPE ) )
{
annot = new PDAnnotationLink(annotDic);
}
else if( subtype.equals( PDAnnotationPopup.SUB_TYPE ) )
{
annot = new PDAnnotationPopup(annotDic);
}
else if( subtype.equals( PDAnnotationRubberStamp.SUB_TYPE ) )
{
annot = new PDAnnotationRubberStamp(annotDic);
}
else if( subtype.equals( PDAnnotationSquareCircle.SUB_TYPE_SQUARE ) ||
subtype.equals( PDAnnotationSquareCircle.SUB_TYPE_CIRCLE ) )
{
annot = new PDAnnotationSquareCircle( annotDic );
}
else if( subtype.equals( PDAnnotationText.SUB_TYPE ) )
{
annot = new PDAnnotationText( annotDic);
}
else if( subtype.equals( PDAnnotationTextMarkup.SUB_TYPE_HIGHLIGHT ) ||
subtype.equals( PDAnnotationTextMarkup.SUB_TYPE_UNDERLINE ) ||
subtype.equals( PDAnnotationTextMarkup.SUB_TYPE_SQUIGGLY ) ||
subtype.equals( PDAnnotationTextMarkup.SUB_TYPE_STRIKEOUT ))
{
annot = new PDAnnotationTextMarkup( annotDic );
}
else if( subtype.equals( PDAnnotationLink.SUB_TYPE ) )
{
annot = new PDAnnotationLink( annotDic );
}
else if( subtype.equals( PDAnnotationWidget.SUB_TYPE ) )
{
annot = new PDAnnotationWidget( annotDic );
}
else
{
annot = new PDAnnotationUnknown( annotDic );
}
}
else
{
throw new IOException( "Error: Unknown annotation type " + base );
}
return annot;
}
Create the correct annotation from the base COS object. |
public int getAnnotationFlags() {
return getDictionary().getInt( "F", 0 );
}
This will get the flags for this field. |
public String getAnnotationName() {
return getDictionary().getString( "NM" );
}
This will get the name, a string intended to uniquely identify each annotation
within a page. Not to be confused with some annotations Name entry which
impact the default image drawn for them. |
public PDAppearanceDictionary getAppearance() {
PDAppearanceDictionary ap = null;
COSDictionary apDic = (COSDictionary)dictionary.getDictionaryObject( COSName.getPDFName( "AP" ) );
if( apDic != null )
{
ap = new PDAppearanceDictionary( apDic );
}
return ap;
}
This will get the appearance dictionary associated with this annotation.
This may return null. |
public String getAppearanceStream() {
String retval = null;
COSName name = (COSName)getDictionary().getDictionaryObject( COSName.getPDFName( "AS" ) );
if( name != null )
{
retval = name.getName();
}
return retval;
}
This will get the name of the current appearance stream if any. |
public COSBase getCOSObject() {
return getDictionary();
}
Interface method for COSObjectable. |
public PDGamma getColour() {
COSArray c = (COSArray) getDictionary().getItem(COSName.getPDFName( "C" ) );
if (c != null)
{
return new PDGamma( c );
}
else
{
return null;
}
}
This will retrieve the colour used in drawing various elements.
As of PDF 1.6 these are : Background of icon when closed
Title bar of popup window
Border of a link annotation
Colour is in DeviceRGB colourspace |
public String getContents() {
return dictionary.getString(COSName.CONTENTS);
}
Get the "contents" of the field. |
public COSDictionary getDictionary() {
return dictionary;
}
|
public String getModifiedDate() {
return getDictionary().getString( "M" );
}
This will retrieve the date and time the annotation was modified. |
public PDPage getPage() {
COSDictionary p = (COSDictionary) this.getDictionary().getDictionaryObject(COSName.P);
if (p != null)
{
return new PDPage(p);
}
return null;
}
This will retrieve the corresponding page of this annotation. |
public PDRectangle getRectangle() {
COSArray rectArray = (COSArray)dictionary.getDictionaryObject( COSName.getPDFName( "Rect" ) );
PDRectangle rectangle = null;
if( rectArray != null )
{
rectangle = new PDRectangle( rectArray );
}
return rectangle;
}
The annotation rectangle, defining the location of the annotation
on the page in default user space units. This is usually required and should
not return null on valid PDF documents. But where this is a parent form field
with children, such as radio button collections then the rectangle will be null. |
public String getSubtype() {
return this.getDictionary().getNameAsString(COSName.SUBTYPE);
}
This will retrieve the subtype of the annotation. |
public boolean isHidden() {
return BitFlagHelper.getFlag( getDictionary(), "F", FLAG_HIDDEN );
}
|
public boolean isInvisible() {
return BitFlagHelper.getFlag( getDictionary(), "F", FLAG_INVISIBLE );
}
|
public boolean isLocked() {
return BitFlagHelper.getFlag( getDictionary(), "F", FLAG_LOCKED );
}
|
public boolean isNoRotate() {
return BitFlagHelper.getFlag( getDictionary(), "F", FLAG_NO_ROTATE );
}
|
public boolean isNoView() {
return BitFlagHelper.getFlag( getDictionary(), "F", FLAG_NO_VIEW );
}
|
public boolean isNoZoom() {
return BitFlagHelper.getFlag( getDictionary(), "F", FLAG_NO_ZOOM );
}
|
public boolean isPrinted() {
return BitFlagHelper.getFlag( getDictionary(), "F", FLAG_PRINTED );
}
|
public boolean isReadOnly() {
return BitFlagHelper.getFlag( getDictionary(), "F", FLAG_READ_ONLY );
}
|
public boolean isToggleNoView() {
return BitFlagHelper.getFlag( getDictionary(), "F", FLAG_TOGGLE_NO_VIEW );
}
Get the toggleNoView flag. |
public void setAnnotationFlags(int flags) {
getDictionary().setInt( "F", flags );
}
This will set the flags for this field. |
public void setAnnotationName(String nm) {
getDictionary().setString( "NM", nm );
}
This will set the name, a string intended to uniquely identify each annotation
within a page. Not to be confused with some annotations Name entry which
impact the default image drawn for them. |
public void setAppearance(PDAppearanceDictionary appearance) {
COSDictionary ap = null;
if( appearance != null )
{
ap = appearance.getDictionary();
}
dictionary.setItem( COSName.getPDFName( "AP" ), ap );
}
This will set the appearance associated with this annotation. |
public void setAppearanceStream(String as) {
if( as == null )
{
getDictionary().removeItem( COSName.getPDFName( "AS" ) );
}
else
{
getDictionary().setItem( COSName.getPDFName( "AS" ), COSName.getPDFName( as ) );
}
}
This will set the annotations appearance stream name. |
public void setColour(PDGamma c) {
getDictionary().setItem( "C", c );
}
This will set the colour used in drawing various elements.
As of PDF 1.6 these are : Background of icon when closed
Title bar of popup window
Border of a link annotation
Colour is in DeviceRGB colourspace |
public void setContents(String value) {
dictionary.setString(COSName.CONTENTS, value);
}
Set the "contents" of the field. |
public void setHidden(boolean hidden) {
BitFlagHelper.setFlag( getDictionary(), "F", FLAG_HIDDEN, hidden );
}
|
public void setInvisible(boolean invisible) {
BitFlagHelper.setFlag( getDictionary(), "F", FLAG_INVISIBLE, invisible );
}
|
public void setLocked(boolean locked) {
BitFlagHelper.setFlag( getDictionary(), "F", FLAG_LOCKED, locked );
}
|
public void setModifiedDate(String m) {
getDictionary().setString( "M", m );
}
This will set the the date and time the annotation was modified. |
public void setNoRotate(boolean noRotate) {
BitFlagHelper.setFlag( getDictionary(), "F", FLAG_NO_ROTATE, noRotate );
}
|
public void setNoView(boolean noView) {
BitFlagHelper.setFlag( getDictionary(), "F", FLAG_NO_VIEW, noView );
}
|
public void setNoZoom(boolean noZoom) {
BitFlagHelper.setFlag( getDictionary(), "F", FLAG_NO_ZOOM, noZoom );
}
|
public void setPrinted(boolean printed) {
BitFlagHelper.setFlag( getDictionary(), "F", FLAG_PRINTED, printed );
}
|
public void setReadOnly(boolean readOnly) {
BitFlagHelper.setFlag( getDictionary(), "F", FLAG_READ_ONLY, readOnly );
}
|
public void setRectangle(PDRectangle rectangle) {
dictionary.setItem( COSName.getPDFName( "Rect" ), rectangle.getCOSArray() );
}
This will set the rectangle for this annotation. |
public void setToggleNoView(boolean toggleNoView) {
BitFlagHelper.setFlag( getDictionary(), "F", FLAG_TOGGLE_NO_VIEW, toggleNoView );
}
Set the toggleNoView flag. |