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<COSObjectable> 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( COSName.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

        Iterator<COSObjectable> widgetIter = widgets.iterator();
        while( widgetIter.hasNext() )
        {
            COSObjectable next = widgetIter.next();
            PDField field = null;
            PDAnnotationWidget widget = null;
            if( next instanceof PDField )
            {
                field = (PDField)next;
                widget = field.getWidget();
            }
            else
            {
                widget = (PDAnnotationWidget)next;
            }
            PDFormFieldAdditionalActions actions = null;
            if( field != null )
            {
                actions = field.getActions();
            }
            if( actions != null &&
                actions.getF() != null &&
                widget.getDictionary().getDictionaryObject( COSName.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

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

      res = false;
    }

    // ---- 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) {
      AnnotationValidator widgetVal = annotFact.getAnnotationValidator( widget.getDictionary(), handler, error);
      widgetVal.validate(error);

      COSBase act = widget.getDictionary().getDictionaryObject(DICTIONARY_KEY_ACTION);
      if (act != null) {
        error.add(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.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget

  protected PDAnnotationWidget pdWidget = null;

  public WidgetAnnotationValidator(DocumentHandler handler,
      COSDictionary annotDictionary) {
    super(handler, annotDictionary);
    this.pdWidget = new PDAnnotationWidget(annotDictionary);
    this.pdAnnot = this.pdWidget;
  }
View Full Code Here

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

        Iterator<COSObjectable> widgetIter = widgets.iterator();
        while( widgetIter.hasNext() )
        {
            COSObjectable next = widgetIter.next();
            PDField field = null;
            PDAnnotationWidget widget = null;
            if( next instanceof PDField )
            {
                field = (PDField)next;
                widget = field.getWidget();
            }
            else
            {
                widget = (PDAnnotationWidget)next;
            }
            PDFormFieldAdditionalActions actions = null;
            if( field != null )
            {
                actions = field.getActions();
            }
            if( actions != null &&
                actions.getF() != null &&
                widget.getDictionary().getDictionaryObject( COSName.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

Examples of org.apache.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<FDFField> fdfKids = fdfField.getKids();
        List<COSObjectable> pdKids = getKids();
View Full Code Here

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<COSObjectable> 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(field);
                    }
                }
                else if ("Widget".equals(kidDictionary.getNameAsString(COSName.SUBTYPE)))
                {
                    kidsList.add(new PDAnnotationWidget(kidDictionary));
                }
                else
                {
                    PDField field = PDFieldFactory.createField(acroForm, kidDictionary);
                    if (field != null)
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
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.