Examples of PDAnnotationWidget


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;
            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);
                }

                PDAppearanceEntry normalAppearance = appearance.getNormalAppearance();
                // TODO support more than one appearance stream
                PDAppearanceStream appearanceStream =
                        normalAppearance.isStream() ? normalAppearance.getAppearanceStream() : null;
                if (appearanceStream == null)
                {
                    COSStream cosStream = acroForm.getDocument().getDocument().createCOSStream();
                    appearanceStream = new PDAppearanceStream(cosStream);
                    appearanceStream.setBBox(widget.getRectangle()
                            .createRetranslatedRectangle());
                    appearance.setNormalAppearance(appearanceStream);
                }

                List<Object> tokens = getStreamTokens(appearanceStream);
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);
            }
            else
            {
                // these are suppose to be ignored if the F is set.
                Integer setF = fdfField.getSetWidgetFieldFlags();
                if (setF != null)
                {
                    annotFlags = annotFlags | setF;
                    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;
                    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.
     */
    public PDAnnotationWidget getWidget()
    {
        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
                {
                    PDFieldTreeNode field = PDFieldTreeNode.createField(acroForm, kidDictionary, this);
                    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 widget annotation"));
                res = false;
View Full Code Here

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

        }
    }

    private void testContentStreamContains( PDDocument doc, PDFieldTreeNode field, String expected ) throws Exception
    {
        PDAnnotationWidget widget = field.getWidget();
        PDAppearanceEntry normalAppearance = widget.getAppearance().getNormalAppearance();
        PDAppearanceStream appearanceStream = normalAppearance.getAppearanceStream();
        COSStream actual = appearanceStream.getCOSStream();

        List<Object> actualTokens = getStreamTokens( doc, actual );
        assertTrue( actualTokens.contains( new COSString( expected ) ) );
View Full Code Here

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

        assertTrue( actualTokens.contains( new COSString( expected ) ) );
    }

    private void testContentStreams( PDDocument doc, PDFieldTreeNode field, String expected ) throws Exception
    {
        PDAnnotationWidget widget = field.getWidget();
        PDAppearanceEntry normalAppearance = widget.getAppearance().getNormalAppearance();
        PDAppearanceStream appearanceStream = normalAppearance.getAppearanceStream();
        COSStream actual = appearanceStream.getCOSStream();

        List<Object> actualTokens = getStreamTokens( doc, actual );
        List<Object> expectedTokens = getStreamTokens( doc, expected );
View Full Code Here

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

    protected PDAnnotationWidget pdWidget = null;

    public WidgetAnnotationValidator(PreflightContext ctx, COSDictionary annotDictionary)
    {
        super(ctx, annotDictionary);
        this.pdWidget = new PDAnnotationWidget(annotDictionary);
        this.pdAnnot = this.pdWidget;
    }
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.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget

    protected PDAnnotationWidget pdWidget = null;

    public WidgetAnnotationValidator(PreflightContext ctx, COSDictionary annotDictionary)
    {
        super(ctx, annotDictionary);
        this.pdWidget = new PDAnnotationWidget(annotDictionary);
        this.pdAnnot = this.pdWidget;
    }
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.