Package org.apache.padaf.preflight.ValidationResult

Examples of org.apache.padaf.preflight.ValidationResult.ValidationError


    if (catalog != null) {
      PDDocumentOutline outlineHierarchy = catalog.getDocumentOutline();
      if (outlineHierarchy != null) {
        // ---- Count entry is mandatory if there are childrens
        if (!isCountEntryPresent(outlineHierarchy.getCOSDictionary()) && (outlineHierarchy.getFirstChild() != null || outlineHierarchy.getLastChild() != null) ) {
          result.add(new ValidationError(
              ERROR_SYNTAX_TRAILER_OUTLINES_INVALID,
              "Outline Hierarchy doesn't have Count entry"));
        } else if (isCountEntryPositive(outlineHierarchy.getCOSDictionary(), handler.getDocument().getDocument())
            && (outlineHierarchy.getFirstChild() == null || outlineHierarchy.getLastChild() == null)) {
          result.add(new ValidationError(ERROR_SYNTAX_TRAILER_OUTLINES_INVALID,
              "Outline Hierarchy doesn't have First and/or Last entry(ies)"));
        } else {
          exploreOutlineLevel(outlineHierarchy.getFirstChild(), handler, result);
        }
      }
View Full Code Here


        .getPDFName(DICTIONARY_KEY_DESTINATION));
    COSBase action = dictionary.getItem(COSName
        .getPDFName(DICTIONARY_KEY_ACTION));

    if (action != null && dest != null) {
      result.add(new ValidationError(ERROR_SYNTAX_TRAILER_OUTLINES_INVALID,
          "Dest entry isn't permitted if the A entry is present"));
      return false;
    } else if (action != null) {
      List<AbstractActionManager> actions = this.actionFact.getActions(dictionary, handler
          .getDocument().getDocument());
      for (AbstractActionManager act : actions) {
        isValid = isValid && act.valid(result);
      }
    } // else no specific validation

    // ---- check children
    PDOutlineItem fChild = inputItem.getFirstChild();
    if (fChild != null) {
      if (!isCountEntryPresent(inputItem.getCOSDictionary())) {
        result
        .add(new ValidationError(ERROR_SYNTAX_TRAILER_OUTLINES_INVALID,
            "Outline item doesn't have Count entry but has at least one descendant."));
        isValid = false;
      } else {
        // ---- there are some descendants, so dictionary must have a Count
        // entry
View Full Code Here

     */
    @Override
    public boolean validate(List<ValidationError> errors)
    throws ValidationException {
      System.out.println("A Custom AnnotationValidator ");
      errors.add(new ValidationError(ERROR));
      return false;
    }
View Full Code Here

 
  public void validateFont(DocumentHandler handler, FontValidator fontVal,
        List<ValidationError> result) throws ValidationException {
    System.out.println("Override the validateFont method");
    super.validateFont(handler, fontVal, result);
    result.add(new ValidationError("UNCODEINCONNU"));
  }
View Full Code Here

   */
  protected void checkNeedAppearences(DocumentHandler handler,
      PDAcroForm acroForm, List<ValidationError> error) {
    if (acroForm.getDictionary().getBoolean(
        ACROFORM_DICTIONARY_KEY_NEED_APPEARANCES, false)) {
      error.add(new ValidationError(ERROR_SYNTAX_DICT_INVALID,
          "NeedAppearance is present with the value \"true\""));
    }
  }
View Full Code Here

  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;
      }
    }
View Full Code Here

  protected void validateLang(DocumentHandler handler,
      PDDocumentCatalog catalog, List<ValidationError> result)
          throws ValidationException {
    String lang = catalog.getLanguage();
    if (lang != null && !"".equals(lang) && !lang.matches("[A-Za-z]{1,8}(-[A-Za-z]{1,8})*")) {
      result.add(new ValidationError(ERROR_SYNTAX_LANG_NOT_RFC1766));
    }
  }
View Full Code Here

          throws ValidationException {
    PDDocumentNameDictionary names = catalog.getNames();
    if (names != null) {
      PDEmbeddedFilesNameTreeNode efs = names.getEmbeddedFiles();
      if (efs != null) {
        result.add(new ValidationError(
            ERROR_SYNTAX_TRAILER_CATALOG_EMBEDDEDFILES,"EmbeddedFile entry is present in the Names dictionary"));
      }
    }
  }
View Full Code Here

          throws ValidationException {
    COSBase ocp = catalog.getCOSDictionary().getItem(
        COSName.getPDFName(DOCUMENT_DICTIONARY_KEY_OPTIONAL_CONTENTS));
    if (ocp != null) {
      result
      .add(new ValidationError(ERROR_SYNTAX_TRAILER_CATALOG_OCPROPERTIES, "A Catalog shall not contain the OCPProperties entry."));
    }
  }
View Full Code Here

    for (int i = 0; outputIntents != null && i < outputIntents.size(); ++i) {
      COSDictionary dictionary = COSUtils.getAsDictionary(outputIntents.get(i), cDoc);

      if (dictionary == null) {

        result.add(new ValidationError(
            ERROR_GRAPHIC_OUTPUT_INTENT_INVALID_ENTRY,
            "OutputIntent object is null or isn't a dictionary"));

      } else {
        // ---- S entry is mandatory and must be equals to GTS_PDFA1
        String sValue = dictionary.getNameAsString(COSName.getPDFName(OUTPUT_INTENT_DICTIONARY_KEY_S));
        if (!OUTPUT_INTENT_DICTIONARY_VALUE_GTS_PDFA1.equals(sValue)) {
          result.add(new ValidationError(ERROR_GRAPHIC_OUTPUT_INTENT_S_VALUE_INVALID,
              "The S entry of the OutputIntent isn't GTS_PDFA1"));
          continue;
        }

        // ---- OutputConditionIdentifier is a mandatory field
        String outputConditionIdentifier = dictionary
            .getString(COSName.getPDFName(OUTPUT_INTENT_DICTIONARY_KEY_OUTPUT_CONDITION_IDENTIFIER));
        if (outputConditionIdentifier == null) {// empty string is autorized (it may be an application specific value)
          result.add(new ValidationError(ERROR_GRAPHIC_OUTPUT_INTENT_INVALID_ENTRY,
              "The OutputIntentCondition is missing"));
          continue;
        }

        // ---- If OutputConditionIdentifier is "Custom" or a non Standard ICC Characterization :
        // ---- DestOutputProfile and Info are mandatory
        // ---- DestOutputProfile must be a ICC Profile

        // ---- Because of PDF/A conforming file needs to specify the color characteristics, the DestOutputProfile
        // ---- is checked even if the OutputConditionIdentifier isn't "Custom"
        COSBase dop = dictionary.getItem(COSName.getPDFName(OUTPUT_INTENT_DICTIONARY_KEY_DEST_OUTPUT_PROFILE));
        ValidationError valer = validateICCProfile(dop, cDoc, tmpDestOutputProfile, handler);
        if (valer != null) {
          result.add(valer);
          continue;
        }
View Full Code Here

TOP

Related Classes of org.apache.padaf.preflight.ValidationResult.ValidationError

Copyright © 2018 www.massapicom. 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.