⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pdannotation.java

📁 非常有用的操作pdf文件的java源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    /**
     * Set the hidden flag.
     * 
     * @param hidden The new hidden flag.
     */
    public void setHidden( boolean hidden )
    {
        BitFlagHelper.setFlag( getDictionary(), "F", FLAG_HIDDEN, hidden );
    }
    
    /**
     * Get the printed flag.
     * 
     * @return The printed flag.
     */
    public boolean isPrinted()
    {
        return BitFlagHelper.getFlag( getDictionary(), "F", FLAG_PRINTED );
    }
    
    /**
     * Set the printed flag.
     * 
     * @param printed The new printed flag.
     */
    public void setPrinted( boolean printed )
    {
        BitFlagHelper.setFlag( getDictionary(), "F", FLAG_PRINTED, printed );
    }
    
    /**
     * Get the noZoom flag.
     * 
     * @return The noZoom flag.
     */
    public boolean isNoZoom()
    {
        return BitFlagHelper.getFlag( getDictionary(), "F", FLAG_NO_ZOOM );
    }
    
    /**
     * Set the noZoom flag.
     * 
     * @param noZoom The new noZoom flag.
     */
    public void setNoZoom( boolean noZoom )
    {
        BitFlagHelper.setFlag( getDictionary(), "F", FLAG_NO_ZOOM, noZoom );
    }
    
    /**
     * Get the noRotate flag.
     * 
     * @return The noRotate flag.
     */
    public boolean isNoRotate()
    {
        return BitFlagHelper.getFlag( getDictionary(), "F", FLAG_NO_ROTATE );
    }
    
    /**
     * Set the noRotate flag.
     * 
     * @param noRotate The new noRotate flag.
     */
    public void setNoRotate( boolean noRotate )
    {
        BitFlagHelper.setFlag( getDictionary(), "F", FLAG_NO_ROTATE, noRotate );
    }
    
    /**
     * Get the noView flag.
     * 
     * @return The noView flag.
     */
    public boolean isNoView()
    {
        return BitFlagHelper.getFlag( getDictionary(), "F", FLAG_NO_VIEW );
    }
    
    /**
     * Set the noView flag.
     * 
     * @param noView The new noView flag.
     */
    public void setNoView( boolean noView )
    {
        BitFlagHelper.setFlag( getDictionary(), "F", FLAG_NO_VIEW, noView );
    }
    
    /**
     * Get the readOnly flag.
     * 
     * @return The readOnly flag.
     */
    public boolean isReadOnly()
    {
        return BitFlagHelper.getFlag( getDictionary(), "F", FLAG_READ_ONLY );
    }
    
    /**
     * Set the readOnly flag.
     * 
     * @param readOnly The new readOnly flag.
     */
    public void setReadOnly( boolean readOnly )
    {
        BitFlagHelper.setFlag( getDictionary(), "F", FLAG_READ_ONLY, readOnly );
    }
    
    /**
     * Get the locked flag.
     * 
     * @return The locked flag.
     */
    public boolean isLocked()
    {
        return BitFlagHelper.getFlag( getDictionary(), "F", FLAG_LOCKED );
    }
    
    /**
     * Set the locked flag.
     * 
     * @param locked The new locked flag.
     */
    public void setLocked( boolean locked )
    {
        BitFlagHelper.setFlag( getDictionary(), "F", FLAG_LOCKED, locked );
    }
    
    /**
     * Get the toggleNoView flag.
     * 
     * @return The toggleNoView flag.
     */
    public boolean isToggleNoView()
    {
        return BitFlagHelper.getFlag( getDictionary(), "F", FLAG_TOGGLE_NO_VIEW );
    }
    
    /**
     * Set the toggleNoView flag.
     * 
     * @param toggleNoView The new toggleNoView flag.
     */
    public void setToggleNoView( boolean toggleNoView )
    {
        BitFlagHelper.setFlag( getDictionary(), "F", FLAG_TOGGLE_NO_VIEW, toggleNoView );
    }
    
    /**
     * Get the action to be performed when this annotation is to be activated.
     * 
     * @return The action to be performed when this annotation is activated.
     * 
     * @throws IOException If there is an error creating the action.
     */
    public PDAction getAction() throws IOException
    {
        COSDictionary action = (COSDictionary)
            getDictionary().getDictionaryObject( COSName.A );
        return PDActionFactory.createAction( action );
    }
    
    /**
     * Set the annotation action.
     * As of PDF 1.6 this is only used for Widget Annotations 
     * @param action The annotation action.
     */
    public void setAction( PDAction action )
    {
        getDictionary().setItem( COSName.A, action );
    }
    
    /**
     * Get the additional actions for this field.  This will return null
     * if there are no additional actions for this field.
     * As of PDF 1.6 this is only used for Widget Annotations.
     * 
     * @return The actions of the field.
     */
    public PDAdditionalActions getActions()
    {
        COSDictionary aa = (COSDictionary)dictionary.getDictionaryObject( "AA" );
        PDAdditionalActions retval = null;
        if( aa != null )
        {
            retval = new PDAdditionalActions( aa );
        }
        return retval;
    }
    
    /**
     * Set the actions of the field.
     * 
     * @param actions The field actions.
     */
    public void setActions( PDAdditionalActions actions )
    {
        dictionary.setItem( "AA", actions );
    }
    
    /**
     * Get the "contents" of the field.
     * 
     * @return the value of the contents.
     */
    public String getContents()
    {
        return dictionary.getString(COSName.CONTENTS);
    }
    
    /**
     * Set the "contents" of the field.
     * 
     * @param value the value of the contents.
     */
    public void setContents( String value)
    {
        dictionary.setString(COSName.CONTENTS, value);
    }
    
    /**
     * This will set the border style dictionary, specifying the width and dash
     * pattern used in drawing the line.
     * 
     * @param bs the border style dictionary to set.
     * 
     */
    public void setBorderStyle( PDBorderStyleDictionary bs )
    {
        getDictionary().setItem( "BS", bs);
    }

    /**
     * This will retrieve the border style dictionary, specifying the width and
     * dash pattern used in drawing the line.
     * 
     * @return the border style dictionary.
     */
    public PDBorderStyleDictionary getBoderStyle()
    {
        COSDictionary bs = (COSDictionary) getDictionary().getItem(
                COSName.getPDFName( "BS" ) );
        if (bs != null)
        {
            return new PDBorderStyleDictionary( bs );
        } 
        else
        {
            return null;
        }
    }

    /**
     * This will retrieve the date and time the annotation was modified.
     * 
     * @return the modified date/time (often in date format, but can be an arbitary string).
     */
    public String getModifiedDate() 
    {
        return getDictionary().getString( "M" );
    }

    /**
     * This will set the the date and time the annotation was modified.
     * 
     * @param m
     *            the date and time the annotation was created.
     */
    public void setModifiedDate( String m )
    {
        getDictionary().setString( "M", m );
    }

    /**
     * This will get the name, a string intended to uniquely identify each annotatoin
     * within a page. Not to be confused with some annotations Name entry which 
     * impact the default image drawn for them.
     * 
     * @return The identifying name for the Annotion.
     */
    public String getAnnotationName() 
    {
        return getDictionary().getString( "NM" );
    }

    /**
     * This will set the name, a string intended to uniquely identify each annotatoin
     * within a page. Not to be confused with some annotations Name entry which 
     * impact the default image drawn for them.
     *
     * @param nm The identifying name for the annotation.
     */
    public void setAnnotationName( String nm )
    {
        getDictionary().setString( "NM", nm );
    }
    
    /**
     * 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
     * 
     * @param c
     *            colour in the DeviceRGB colourspace
     * 
     */
    public void setColour( PDGamma c )
    {
        getDictionary().setItem( "C", c );
    }

    /**
     * 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
     * 
     * @return PDGamma object representing the colour
     * 
     */
    public PDGamma getColour()
    {
        COSArray c = (COSArray) getDictionary().getItem(COSName.getPDFName( "C" ) );
        if (c != null)
        {
            return new PDGamma( c );
        } 
        else
        {
            return null;
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -