Package org.apache.padaf.preflight.ValidationResult

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


    COSBase d = this.actionDictionnary.getItem(COSName
        .getPDFName(ACTION_DICTIONARY_KEY_D));

    // ---- D entry is mandatory
    if (d == null) {
      error.add(new ValidationError(ERROR_ACTION_MISING_KEY,
          "D entry is mandatory for the ThreadAction"));
      return false;
    }

    if (!(COSUtils.isInteger(d, cDoc) || COSUtils.isString(d, cDoc) || COSUtils
        .isDictionary(d, cDoc))) {
      error.add(new ValidationError(ERROR_ACTION_INVALID_TYPE, "D entry type is invalid"));
      return false;
    }

    return true;
  }
View Full Code Here


      PDStream pstream = page.getContents();
      if (pstream != null) {
        processStream(page, page.findResources(), pstream.getStream());
      }
    } catch (ContentStreamException e) {
      errors.add(new ValidationError(e.getValidationError(), e.getMessage()));
    } catch (IOException e) {
      throw new ValidationException("Unable to check the ContentStream : "
          + e.getMessage(), e);
    }
View Full Code Here

    try {
      resetEnginContext();
      processSubStream(null, xobj.getResources(), xobj.getCOSStream());
    } catch (ContentStreamException e) {
      errors.add(new ValidationError(e.getValidationError(), e.getMessage()));
    } catch (IOException e) {
      throw new ValidationException("Unable to check the ContentStream : "
          + e.getMessage(), e);
    }
View Full Code Here

      COSDictionary res = (COSDictionary) pattern
          .getDictionaryObject(DICTIONARY_KEY_RESOURCES);
      resetEnginContext();
      processSubStream(null, new PDResources(res), pattern);
    } catch (ContentStreamException e) {
      errors.add(new ValidationError(e.getValidationError(), e.getMessage()));
    } catch (IOException e) {
      throw new ValidationException("Unable to check the ContentStream : "
          + e.getMessage(), e);
    }
View Full Code Here

   * This method updates the given list with a ValidationError
   * (ERROR_GRAPHIC_INVALID_PATTERN_COLOR_SPACE_FORBIDDEN) and returns false.
   */
  protected boolean processPatternColorSpace(List<ValidationError> result) {
    result
        .add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE_FORBIDDEN, "Pattern ColorSpace is forbidden"));
    return false;
  }
View Full Code Here

   * (ERROR_GRAPHIC_INVALID_PATTERN_COLOR_SPACE_FORBIDDEN) and returns false.
   */
  protected boolean processDeviceNColorSpace(PDColorSpace pdcs,
      List<ValidationError> result) {
    result
        .add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE_FORBIDDEN, "DeviceN ColorSpace is forbidden"));
    return false;
  }
View Full Code Here

      ColorSpaces cs = ColorSpaces.valueOf(based.getName());
      switch (cs) {     
      case Indexed:
      case Indexed_SHORT:
      case Pattern:
        result.add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE_FORBIDDEN, cs.getLabel() + " ColorSpace is forbidden"));
        return false;
       
      default:
        return processAllColorSpace(based, result);
      }

    } catch (IOException e) {
      result.add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE, "Unable to read Indexed Color Space : " + e.getMessage()));
      return false;
    }
  }
View Full Code Here

    all = all && (this.fontEncoding != null);
    all = all && (this.firstChar != null);
    all = all && (this.lastChar != null);
    all = all && (this.widths != null);
    if (!all) {
      this.fontContainer.addError(new ValidationError(
          ERROR_FONTS_DICTIONARY_INVALID));
    }

    /*
     * ---- Since PDF 1.5 : FontDescriptor is mandatory for Type3 font. However
View Full Code Here

    COSDocument cDoc = this.handler.getDocument().getDocument();

    // ---- both elements are an array
    if (!COSUtils.isArray(this.fontBBox, cDoc)) {
      this.fontContainer
      .addError(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID,
          "The FontBBox element isn't an array"));
      return false;
    }

    if (!COSUtils.isArray(this.fontMatrix, cDoc)) {
      this.fontContainer.addError(new ValidationError(
          ERROR_FONTS_DICTIONARY_INVALID,
          "The FontMatrix element isn't an array"));
      return false;
    }

    // ---- check the content of the FontBBox.
    // ---- Should be an array with 4 numbers
    COSArray bbox = COSUtils.getAsArray(fontBBox, cDoc);
    if (bbox.size() != 4) {
      this.fontContainer.addError(new ValidationError(
          ERROR_FONTS_DICTIONARY_INVALID, "The FontBBox element is invalid"));
      return false;
    } else {
      for (int i = 0; i < 4; i++) {
        COSBase elt = bbox.get(i);
        if (!(COSUtils.isFloat(elt, cDoc) || COSUtils.isInteger(elt, cDoc))) {
          this.fontContainer.addError(new ValidationError(
              ERROR_FONTS_DICTIONARY_INVALID,
              "An element of FontBBox isn't a number"));
          return false;
        }
      }
    }

    // ---- check the content of the FontMatrix.
    // ---- Should be an array with 6 numbers
    COSArray matrix = COSUtils.getAsArray(fontMatrix, cDoc);
    if (matrix.size() != 6) {
      this.fontContainer.addError(new ValidationError(
          ERROR_FONTS_DICTIONARY_INVALID, "The FontMatrix element is invalid"));
      return false;
    } else {
      for (int i = 0; i < 6; i++) {
        COSBase elt = matrix.get(i);
        if (!(COSUtils.isFloat(elt, cDoc) || COSUtils.isInteger(elt, cDoc))) {
          this.fontContainer.addError(new ValidationError(
              ERROR_FONTS_DICTIONARY_INVALID,
              "An element of FontMatrix isn't a number"));
          return false;
        }
      }
View Full Code Here

      String enc = COSUtils.getAsString(this.fontEncoding, cDoc);
      try {
        type3Encoding = emng.getEncoding(COSName.getPDFName(enc));
      } catch (IOException e) {
        // ---- the encoding doesn't exist
        this.fontContainer.addError(new ValidationError(ERROR_FONTS_ENCODING));
        return false;
      }
    } else if (COSUtils.isDictionary(this.fontEncoding, cDoc)) {
      COSDictionary encodingDictionary = COSUtils.getAsDictionary(
          this.fontEncoding, cDoc);
      try {
        type3Encoding = new DictionaryEncoding(encodingDictionary);
      } catch (IOException e) {
        // ---- the encoding doesn't exist
        this.fontContainer.addError(new ValidationError(ERROR_FONTS_ENCODING));
        return false;
      }

      COSBase diff = encodingDictionary.getItem(COSName
          .getPDFName(FONT_DICTIONARY_KEY_DIFFERENCES));
      if (diff != null) {
        if (!COSUtils.isArray(diff, cDoc)) {
          this.fontContainer
          .addError(new ValidationError(ERROR_FONTS_TYPE3_DAMAGED,
              "The differences element of the encoding dictionary isn't an array"));
          return false;
        }

        // ---- The DictionaryEncoding object doesn't throw exception if the
        // Differences isn't well formed.
        // So check if the array has the right format.
        COSArray differences = COSUtils.getAsArray(diff, cDoc);
        for (int i = 0; i < differences.size(); ++i) {
          COSBase item = differences.get(i);
          if (!(item instanceof COSInteger || item instanceof COSName)) {
            // ---- Error, the Differences array is invalid
            this.fontContainer
            .addError(new ValidationError(ERROR_FONTS_TYPE3_DAMAGED,
                "Differences Array should contain COSInt or COSName, no other type"));
            return false;
          }
        }
      }
    } else {
      // ---- the encoding entry is invalid
      this.fontContainer.addError(new ValidationError(
          ERROR_FONTS_TYPE3_DAMAGED,
          "The Encoding entry doesn't have the right type"));
      return false;
    }
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.