List of usage examples for org.apache.pdfbox.pdmodel.interactive.form PDField getActions
public PDFormFieldAdditionalActions getActions()
From source file:net.padaf.preflight.helpers.AcroFormValidationHelper.java
License:Apache License
/** * A and AA field are forbidden, this method checks if they are present and * checks all child of this field. If the an Additional Action is present the * error code ERROR_ACTION_FORBIDDEN_ADDITIONAL_ACTIONS_FIELD (6.2.3) is added * to the error list If the an Action is present (in the Widget Annotation) * the error ERROR_ACTION_FORBIDDEN_WIDGET_ACTION_FIELD (6.2.4) is added to * the error list. (Remark : The widget validation will be done by the * AnnotationValidationHelper, but some actions are authorized in a standard * Widget)/*www.ja v a 2s . com*/ * * @param aField * @param handler * @param result * @return * @throws IOException */ protected boolean valideField(PDField aField, DocumentHandler handler, List<ValidationError> error) throws IOException, ValidationException { boolean res = true; PDFormFieldAdditionalActions aa = aField.getActions(); if (aa != null) { error.add(new ValidationError(ERROR_ACTION_FORBIDDEN_ADDITIONAL_ACTIONS_FIELD, "\"AA\" must not be used in a Field dictionary")); 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; } } res = res && exploreFields(handler, aField.getKids(), error); return res; }
From source file:org.apache.tika.parser.pdf.AbstractPDF2XHTML.java
License:Apache License
private void processAcroField(PDField field, final int currentRecursiveDepth) throws SAXException, IOException, TikaException { if (currentRecursiveDepth >= MAX_ACROFORM_RECURSIONS) { return;/* ww w .jav a 2 s . c o m*/ } PDFormFieldAdditionalActions pdFormFieldAdditionalActions = field.getActions(); if (pdFormFieldAdditionalActions != null) { handleDestinationOrAction(pdFormFieldAdditionalActions.getC(), ActionTrigger.FORM_FIELD_RECALCULATE); handleDestinationOrAction(pdFormFieldAdditionalActions.getF(), ActionTrigger.FORM_FIELD_FORMATTED); handleDestinationOrAction(pdFormFieldAdditionalActions.getK(), ActionTrigger.FORM_FIELD_KEYSTROKE); handleDestinationOrAction(pdFormFieldAdditionalActions.getV(), ActionTrigger.FORM_FIELD_VALUE_CHANGE); } if (field.getWidgets() != null) { for (PDAnnotationWidget widget : field.getWidgets()) { handleWidget(widget); } } addFieldString(field); if (field instanceof PDNonTerminalField) { int r = currentRecursiveDepth + 1; xhtml.startElement("ol"); for (PDField child : ((PDNonTerminalField) field).getChildren()) { processAcroField(child, r); } xhtml.endElement("ol"); } }