Examples of PDAnnotationWidget


Examples of org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget

     * @return The widget that is associated with this field.
     * @throws IOException If there is an error getting the widget object.
     */
    public PDAnnotationWidget getWidget() throws IOException
    {
        PDAnnotationWidget retval = null;
        List kids = getKids();
        if( kids == null )
        {
            retval = new PDAnnotationWidget( getDictionary() );
        }
        else if( kids.size() > 0 )
        {
            Object firstKid = kids.get( 0 );
            if( firstKid instanceof PDAnnotationWidget )
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget

                {
                    kidsList.add( PDFieldFactory.createField( acroForm, kidDictionary ));
                }
                else if( "Widget".equals( kidDictionary.getNameAsString( "Subtype" ) ) )
                {
                    kidsList.add( new PDAnnotationWidget( kidDictionary ) );
                }
                else
                {
                    //
                    kidsList.add( PDFieldFactory.createField( acroForm, kidDictionary ));
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget

        }

        /*
         * The widget validation will be done by the widget annotation, a widget contained in a Field can't have action.
         */
        PDAnnotationWidget widget = aField.getWidget();
        if (res && widget != null)
        {
            ContextHelper.validateElement(ctx, widget.getDictionary(), ANNOTATIONS_PROCESS);
            COSBase act = widget.getDictionary().getDictionaryObject(COSName.A);
            if (act != null)
            {
                addValidationError(ctx, new ValidationError(ERROR_ACTION_FORBIDDEN_WIDGET_ACTION_FIELD,
                        "\"A\" must not be used in a Field dictionary"));
                res = false;
View Full Code Here

Examples of org.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget

                fieldFlags = fieldFlags & clrFfValue;
                setFieldFlags( fieldFlags );
            }
        }

        PDAnnotationWidget widget = getWidget();
        if( widget != null )
        {
            int annotFlags = widget.getAnnotationFlags();
            Integer f = fdfField.getWidgetFieldFlags();
            if( f != null && widget != null )
            {
                widget.setAnnotationFlags( f.intValue() );
            }
            else
            {
                //these are suppose to be ignored if the F is set.
                Integer setF = fdfField.getSetWidgetFieldFlags();
                if( setF != null )
                {
                    annotFlags = annotFlags | setF.intValue();
                    widget.setAnnotationFlags( annotFlags );
                }

                Integer clrF = fdfField.getClearWidgetFieldFlags();
                if( clrF != null )
                {
                    //we have to clear the bits of the document fields for every bit that is
                    //set in this field.
                    //
                    //Example:
                    //docF = 1011
                    //clrF = 1101
                    //clrFValue = 0010;
                    //newValue = 1011 & 0010 which is 0010
                    int clrFValue = clrF.intValue();
                    clrFValue ^= 0xFFFFFFFFL;
                    annotFlags = annotFlags & clrFValue;
                    widget.setAnnotationFlags( annotFlags );
                }
            }
        }
        List fdfKids = fdfField.getKids();
        List pdKids = getKids();
View Full Code Here

Examples of org.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget

     * @return The widget that is associated with this field.
     * @throws IOException If there is an error getting the widget object.
     */
    public PDAnnotationWidget getWidget() throws IOException
    {
        PDAnnotationWidget retval = null;
        List kids = getKids();
        if( kids == null )
        {
            retval = new PDAnnotationWidget( getDictionary() );
        }
        else if( kids.size() > 0 )
        {
            Object firstKid = kids.get( 0 );
            if( firstKid instanceof PDAnnotationWidget )
View Full Code Here

Examples of org.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget

                {
                    kidsList.add( PDFieldFactory.createField( acroForm, kidDictionary ));
                }
                else if( "Widget".equals( kidDictionary.getNameAsString( "Subtype" ) ) )
                {
                    kidsList.add( new PDAnnotationWidget( kidDictionary ) );
                }
                else
                {
                    //
                    kidsList.add( PDFieldFactory.createField( acroForm, kidDictionary ));
View Full Code Here

Examples of org.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget

        }
    }
   
    private void testContentStreamContains( PDDocument doc, PDField field, String expected ) throws Exception
    {
        PDAnnotationWidget widget = field.getWidget();
        Map normalAppearance = widget.getAppearance().getNormalAppearance();
        PDAppearanceStream appearanceStream = (PDAppearanceStream)normalAppearance.get( "default" );
        COSStream actual = appearanceStream.getStream();
       
        List actualTokens = getStreamTokens( doc, actual );
        assertTrue( actualTokens.contains( new COSString( expected ) ) );
View Full Code Here

Examples of org.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget

        assertTrue( actualTokens.contains( new COSString( expected ) ) );
    }
   
    private void testContentStreams( PDDocument doc, PDField field, String expected ) throws Exception
    {
        PDAnnotationWidget widget = field.getWidget();
        Map normalAppearance = widget.getAppearance().getNormalAppearance();
        PDAppearanceStream appearanceStream = (PDAppearanceStream)normalAppearance.get( "default" );
        COSStream actual = appearanceStream.getStream();
       
        List actualTokens = getStreamTokens( doc, actual );
        List expectedTokens = getStreamTokens( doc, expected );
View Full Code Here

Examples of org.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget

        value = apValue;
        Iterator widgetIter = widgets.iterator();
        while( widgetIter.hasNext() )
        {
            Object next = widgetIter.next();
            PDAnnotationWidget widget = null;
            if( next instanceof PDField )
            {
                widget = ((PDField)next).getWidget();
            }
            else
            {
                widget = (PDAnnotationWidget)next;
            }
            PDAdditionalActions actions = widget.getActions();
            if( actions != null &&
                actions.getF() != null &&
                widget.getDictionary().getDictionaryObject( "AP" ) ==null)
            {
                //do nothing because the field will be formatted by acrobat
                //when it is opened.  See FreedomExpressions.pdf for an example of this.
            }
            else
            {
           
                PDAppearanceDictionary appearance = widget.getAppearance();
                if( appearance == null )
                {
                    appearance = new PDAppearanceDictionary();
                    widget.setAppearance( appearance );
                }
   
                Map normalAppearance = appearance.getNormalAppearance();
                PDAppearanceStream appearanceStream = (PDAppearanceStream)normalAppearance.get( "default" );
                if( appearanceStream == null )
                {
                    COSStream cosStream = new COSStream( acroForm.getDocument().getDocument().getScratchFile() );
                    appearanceStream = new PDAppearanceStream( cosStream );
                    appearanceStream.setBoundingBox( widget.getRectangle().createRetranslatedRectangle() );
                    appearance.setNormalAppearance( appearanceStream );
                }
               
                List tokens = getStreamTokens( appearanceStream );
                List daTokens = getStreamTokens( getDefaultAppearance() );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.