/** * 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) { this.getCOSObject().setItem(COSName.BS, bs); }
/** * Sets the appearance characteristics dictionary. * * @param appearanceCharacteristics the appearance characteristics dictionary */ public void setAppearanceCharacteristics( PDAppearanceCharacteristicsDictionary appearanceCharacteristics) { this.getCOSObject().setItem(COSName.MK, appearanceCharacteristics); }
/** * Constructor. */ public PDAnnotationWidget() { getCOSObject().setName(COSName.SUBTYPE, SUB_TYPE); }
/** * Creates a PDWidget from a COSDictionary, expected to be a correct object definition for a field in PDF. * * @param field the PDF object to represent as a field. */ public PDAnnotationWidget(COSDictionary field) { super(field); getCOSObject().setName(COSName.SUBTYPE, SUB_TYPE); }
/** * Set the actions of the field. * * @param actions The field actions. */ public void setActions(PDAnnotationAdditionalActions actions) { this.getCOSObject().setItem(COSName.AA, actions); }
/** * 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) { this.getCOSObject().setItem(COSName.A, action); }
/** * Check if the widget already exists in the annotation list * * @param acroFormFields the list of AcroForm fields. * @param signatureField the signature field. * @return true if the widget already existed in the annotation list, false if not. */ private boolean checkSignatureAnnotation(List<PDAnnotation> annotations, PDAnnotationWidget widget) { for (PDAnnotation annotation : annotations) { if (annotation.getCOSObject().equals(widget.getCOSObject())) { return true; } } return false; }
/** * This function explores all fields and their children to validate them. * * @see #validateField(PreflightContext, PDField) * * @param ctx the preflight context. * @param widgets the list of widgets * @return the result of the validation. * @throws IOException */ protected boolean exploreWidgets(PreflightContext ctx, List<PDAnnotationWidget> widgets) throws IOException { for (PDAnnotationWidget widget : widgets) { // "A field's children in the hierarchy may also include widget annotations" ContextHelper.validateElement(ctx, widget.getCOSObject(), ANNOTATIONS_PROCESS); } return true; }
/** * Set the parent field of a widget annotation. This is only required if this widget annotation * is one of multiple children in a field, and not to be set otherwise. You will usually not * need this, because in most cases, fields have only one widget and share a common dictionary. * A usage can be found in the CreateMultiWidgetsForm example. * * @param field the parent field. * @throws IllegalArgumentException if setParent() was called for a field that shares a * dictionary with its only widget. */ public void setParent(PDTerminalField field) { if (this.getCOSObject().equals(field.getCOSObject())) { throw new IllegalArgumentException("setParent() is not to be called for a field that shares a dictionary with its only widget"); } this.getCOSObject().setItem(COSName.PARENT, field); } }
/** * Returns the highlighting mode. Default value: <code>I</code> * <dl> * <dt><code>N</code></dt> * <dd>(None) No highlighting.</dd> * <dt><code>I</code></dt> * <dd>(Invert) Invert the contents of the annotation rectangle.</dd> * <dt><code>O</code></dt> * <dd>(Outline) Invert the annotation's border.</dd> * <dt><code>P</code></dt> * <dd>(Push) Display the annotation's down appearance, if any. If no down appearance is defined, the contents of * the annotation rectangle shall be offset to appear as if it were pushed below the surface of the page</dd> * <dt><code>T</code></dt> * <dd>(Toggle) Same as <code>P</code> (which is preferred).</dd> * </dl> * * @return the highlighting mode */ public String getHighlightingMode() { return this.getCOSObject().getNameAsString(COSName.H, "I"); }
|| "P".equals(highlightingMode) || "T".equals(highlightingMode)) this.getCOSObject().setName(COSName.H, highlightingMode);
/** * 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 getBorderStyle() { COSBase bs = getCOSObject().getDictionaryObject(COSName.BS); if (bs instanceof COSDictionary) { return new PDBorderStyleDictionary((COSDictionary) bs); } return null; }
/** * Returns the appearance characteristics dictionary. * * @return the appearance characteristics dictionary */ public PDAppearanceCharacteristicsDictionary getAppearanceCharacteristics() { COSBase mk = this.getCOSObject().getDictionaryObject(COSName.MK); if (mk instanceof COSDictionary) { return new PDAppearanceCharacteristicsDictionary((COSDictionary) mk); } return null; }
/** * Get the action to be performed when this annotation is to be activated. * * @return The action to be performed when this annotation is activated. */ public PDAction getAction() { COSBase base = this.getCOSObject().getDictionaryObject(COSName.A); if (base instanceof COSDictionary) { return PDActionFactory.createAction((COSDictionary) base); } return null; }
/** * 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 PDAnnotationAdditionalActions getActions() { COSBase base = this.getCOSObject().getDictionaryObject(COSName.AA); if (base instanceof COSDictionary) { return new PDAnnotationAdditionalActions((COSDictionary) base); } return null; }
widgetsForPage.put(widget.getCOSObject(), widget); pagesAnnotationsMap.put(pageForWidget.getCOSObject(), widgetsForPage); widgetsForPage.put(widget.getCOSObject(), widget);
@Override public void createWidgetDictionary(PDSignatureField signatureField, PDResources holderFormResources) throws IOException { COSDictionary widgetDict = signatureField.getWidgets().get(0).getCOSObject(); widgetDict.setNeedToBeUpdated(true); widgetDict.setItem(COSName.DR, holderFormResources.getCOSObject()); pdfStructure.setWidgetDictionary(widgetDict); LOG.info("WidgetDictionary has been created"); }
private PDDefaultAppearanceString getWidgetDefaultAppearanceString(PDAnnotationWidget widget) throws IOException { COSString da = (COSString) widget.getCOSObject().getDictionaryObject(COSName.DA); PDResources dr = field.getAcroForm().getDefaultResources(); return new PDDefaultAppearanceString(da, dr); }
/** * Sets the field's widget annotations. * * @param children The list of widget annotations. */ public void setWidgets(List<PDAnnotationWidget> children) { COSArray kidsArray = COSArrayList.converterToCOSArray(children); getCOSObject().setItem(COSName.KIDS, kidsArray); for (PDAnnotationWidget widget : children) { widget.getCOSObject().setItem(COSName.PARENT, this); } }
ContextHelper.validateElement(ctx, ((PDAnnotationWidget) obj).getCOSObject(), ANNOTATIONS_PROCESS);