Examples of ColorSpaceHelper


Examples of org.apache.padaf.preflight.graphics.color.ColorSpaceHelper

    COSDocument doc = this.documentHandler.getDocument().getDocument();
    COSBase csInlinedBase = dict.getItem(COSName
        .getPDFName(STREAM_DICTIONARY_KEY_COLOR_SPACE));

    ColorSpaceHelper csHelper = null;
    if (csInlinedBase != null) {

      if (COSUtils.isString(csInlinedBase, doc)) {
        // ---- In InlinedImage only DeviceGray/RGB/CMYK and restricted Indexed
        // color spaces
        // are allowed.
        String colorSpace = COSUtils.getAsString(csInlinedBase, doc);
        ColorSpaces cs = null;

        try {
          cs = ColorSpaces.valueOf(colorSpace);
        } catch (IllegalArgumentException e) {
          // ---- The color space is unknown.
          // ---- Try to access the resources dictionary, the color space can be
          // a reference.
          PDColorSpace pdCS = (PDColorSpace) this.getColorSpaces().get(
              colorSpace);
          if (pdCS != null) {
            cs = ColorSpaces.valueOf(pdCS.getName());
            csHelper = ColorSpaceHelperFactory.getColorSpaceHelper(pdCS,
                documentHandler, ColorSpaceRestriction.ONLY_DEVICE);
          }
        }

        if (cs == null) {
          throwContentStreamException("The ColorSpace is unknown",
              ERROR_GRAPHIC_UNEXPECTED_VALUE_FOR_KEY);
        }
      }

      if (csHelper == null) {
        csHelper = ColorSpaceHelperFactory.getColorSpaceHelper(csInlinedBase,
            documentHandler, ColorSpaceRestriction.ONLY_DEVICE);
      }
      List<ValidationError> errors = new ArrayList<ValidationError>();
      try {
        if (!csHelper.validate(errors)) {
          ValidationError ve = errors.get(0);
          throwContentStreamException(ve.getDetails(), ve.getErrorCode());
        }
      } catch (ValidationException e) {
        throw new IOException(e.getMessage());
View Full Code Here

Examples of org.apache.padaf.preflight.graphics.color.ColorSpaceHelper

    } else {
      throwContentStreamException("The operand doesn't have the expected type",
          ERROR_GRAPHIC_UNEXPECTED_VALUE_FOR_KEY);
    }

    ColorSpaceHelper csHelper = null;
    ColorSpaces cs = null;
    try {
      cs = ColorSpaces.valueOf(colorSpaceName);
    } catch (IllegalArgumentException e) {
      // ---- The color space is unknown.
      // ---- Try to access the resources dictionary, the color space can be a
      // reference.
      PDColorSpace pdCS = (PDColorSpace) this.getColorSpaces().get(
          colorSpaceName);
      if (pdCS != null) {
        cs = ColorSpaces.valueOf(pdCS.getName());
        csHelper = ColorSpaceHelperFactory.getColorSpaceHelper(pdCS,
            documentHandler, ColorSpaceRestriction.NO_RESTRICTION);
      }
    }

    if (cs == null) {
      throwContentStreamException("The ColorSpace is unknown",
          ERROR_GRAPHIC_UNEXPECTED_VALUE_FOR_KEY);
    }

    if (csHelper == null) {
      csHelper = ColorSpaceHelperFactory.getColorSpaceHelper(COSName
          .getPDFName(colorSpaceName), documentHandler,
          ColorSpaceRestriction.NO_RESTRICTION);
    }

    List<ValidationError> errors = new ArrayList<ValidationError>();
    try {
      if (!csHelper.validate(errors)) {
        ValidationError ve = errors.get(0);
        throwContentStreamException(ve.getDetails(), ve.getErrorCode());
      }
    } catch (ValidationException e) {
      //      throw new IOException(e.getMessage(), e); java 6
View Full Code Here

Examples of org.apache.padaf.preflight.graphics.color.ColorSpaceHelper

      if (bitsPerCompValue != 1 ) {
        result.add(new ValidationError(ERROR_GRAPHIC_UNEXPECTED_VALUE_FOR_KEY, "ImageMask entry is true, BitsPerComponent must be 1."));
      }

    } else {
      ColorSpaceHelper csh = ColorSpaceHelperFactory.getColorSpaceHelper(csImg, handler, ColorSpaceRestriction.NO_PATTERN);
      csh.validate(result);
    }
  }
View Full Code Here

Examples of org.apache.padaf.preflight.graphics.color.ColorSpaceHelper

      return false;
    }

    COSBase csImg = shadingDict.getItem(COSName
        .getPDFName(XOBJECT_DICTIONARY_KEY_COLOR_SPACE));
    ColorSpaceHelper csh = ColorSpaceHelperFactory.getColorSpaceHelper(csImg,
        documentHandler, ColorSpaceRestriction.NO_PATTERN);
    return csh.validate(errors);
  }
View Full Code Here

Examples of org.apache.pdfbox.preflight.graphic.ColorSpaceHelper

        try
        {
            PDColorSpace pColorSpace = shadingRes.getColorSpace();
            PreflightConfiguration config = context.getConfig();
            ColorSpaceHelperFactory csFact = config.getColorSpaceHelperFact();
            ColorSpaceHelper csh = csFact.getColorSpaceHelper(context, pColorSpace, ColorSpaceRestriction.NO_PATTERN);
            csh.validate();
        }
        catch (IOException e)
        {
            context.addValidationError(new ValidationError(ERROR_GRAPHIC_INVALID_UNKNOWN_COLOR_SPACE, e.getMessage()));
        }
View Full Code Here

Examples of org.apache.pdfbox.preflight.graphic.ColorSpaceHelper

            for (COSName name : resources.getColorSpaceNames())
            {
                try
                {
                    PDColorSpace pdCS = resources.getColorSpace(name);
                    ColorSpaceHelper csHelper = colorSpaceFactory.getColorSpaceHelper(context, pdCS,
                            ColorSpaceRestriction.NO_RESTRICTION);
                    csHelper.validate();
                }
                catch (IOException e)
                {
                    // fixme: this code was previously in PDResources
                    // LOG.error("error while creating a colorspace", exception);
View Full Code Here

Examples of org.apache.pdfbox.preflight.graphic.ColorSpaceHelper

            try
            {
                PreflightConfiguration config = context.getConfig();
                ColorSpaceHelperFactory csFact = config.getColorSpaceHelperFact();
                PDColorSpace pdCS = PDColorSpace.create(csImg);
                ColorSpaceHelper csh = csFact.getColorSpaceHelper(context, pdCS, ColorSpaceRestriction.NO_PATTERN);
                csh.validate();
            }
            catch (IOException e)
            {
                context.addValidationError(new ValidationError(ERROR_GRAPHIC_INVALID_UNKNOWN_COLOR_SPACE));
            }
View Full Code Here

Examples of org.apache.pdfbox.preflight.graphic.ColorSpaceHelper

    protected void validImageColorSpace(Operator operator) throws IOException
    {
        COSDictionary dict = operator.getImageParameters();

        COSBase csInlinedBase = dict.getItem(COSName.CS);
        ColorSpaceHelper csHelper = null;
        if (csInlinedBase != null)
        {
            if (COSUtils.isString(csInlinedBase, cosDocument))
            {
                // In InlinedImage only DeviceGray/RGB/CMYK and restricted Indexed
                // color spaces are allowed.
                String colorSpace = COSUtils.getAsString(csInlinedBase, cosDocument);
                ColorSpaces cs = null;

                try
                {
                    cs = ColorSpaces.valueOf(colorSpace);
                }
                catch (IllegalArgumentException e)
                {
                    // The color space is unknown. Try to access the resources dictionary,
                    // the color space can be a reference.
                    PDColorSpace pdCS = this.getResources().getColorSpace(COSName.getPDFName(colorSpace));
                    if (pdCS != null)
                    {
                        cs = ColorSpaces.valueOf(pdCS.getName());
                        PreflightConfiguration cfg = context.getConfig();
                        ColorSpaceHelperFactory csFact = cfg.getColorSpaceHelperFact();
                        csHelper = csFact.getColorSpaceHelper(context, pdCS, ColorSpaceRestriction.ONLY_DEVICE);
                    }
                }

                if (cs == null)
                {
                    registerError("The ColorSpace is unknown", ERROR_GRAPHIC_UNEXPECTED_VALUE_FOR_KEY);
                    return;
                }
            }

            if (csHelper == null)
            {
                PDColorSpace pdCS = PDColorSpace.create(csInlinedBase);
                PreflightConfiguration cfg = context.getConfig();
                ColorSpaceHelperFactory csFact = cfg.getColorSpaceHelperFact();
                csHelper = csFact.getColorSpaceHelper(context, pdCS, ColorSpaceRestriction.ONLY_DEVICE);
            }

            csHelper.validate();
        }
    }
View Full Code Here

Examples of org.apache.pdfbox.preflight.graphic.ColorSpaceHelper

        {
            registerError("The operand doesn't have the expected type", ERROR_GRAPHIC_UNEXPECTED_VALUE_FOR_KEY);
            return;
        }

        ColorSpaceHelper csHelper = null;
        ColorSpaces cs = null;
        try
        {
            cs = ColorSpaces.valueOf(colorSpaceName);
        }
        catch (IllegalArgumentException e)
        {
            /*
             * The color space is unknown. Try to access the resources dictionary, the color space can be a reference.
             */
            PDColorSpace pdCS = this.getResources().getColorSpace(COSName.getPDFName(colorSpaceName));
            if (pdCS != null)
            {
                cs = ColorSpaces.valueOf(pdCS.getName());
                PreflightConfiguration cfg = context.getConfig();
                ColorSpaceHelperFactory csFact = cfg.getColorSpaceHelperFact();
                csHelper = csFact.getColorSpaceHelper(context, pdCS, ColorSpaceRestriction.NO_RESTRICTION);
            }
        }

        if (cs == null)
        {
            registerError("The ColorSpace is unknown", ERROR_GRAPHIC_UNEXPECTED_VALUE_FOR_KEY);
            return;
        }

        if (csHelper == null)
        {
            PDColorSpace pdCS = PDColorSpace.create(COSName.getPDFName(colorSpaceName));
            PreflightConfiguration cfg = context.getConfig();
            ColorSpaceHelperFactory csFact = cfg.getColorSpaceHelperFact();
            csHelper = csFact.getColorSpaceHelper(context, pdCS, ColorSpaceRestriction.NO_RESTRICTION);
        }

        csHelper.validate();
    }
View Full Code Here

Examples of org.apache.pdfbox.preflight.graphic.ColorSpaceHelper

    protected void validImageColorSpace(PDFOperator operator) throws ContentStreamException, IOException
    {
        COSDictionary dict = operator.getImageParameters().getDictionary();

        COSBase csInlinedBase = dict.getItem(COSName.CS);
        ColorSpaceHelper csHelper = null;
        if (csInlinedBase != null)
        {
            if (COSUtils.isString(csInlinedBase, cosDocument))
            {
                /*
                 * In InlinedImage only DeviceGray/RGB/CMYK and restricted Indexed color spaces are allowed.
                 */
                String colorSpace = COSUtils.getAsString(csInlinedBase, cosDocument);
                ColorSpaces cs = null;

                try
                {
                    cs = ColorSpaces.valueOf(colorSpace);
                }
                catch (IllegalArgumentException e)
                {
                    /*
                     * The color space is unknown. Try to access the resources dictionary, the color space can be a
                     * reference.
                     */
                    PDColorSpace pdCS = (PDColorSpace) this.getColorSpaces().get(colorSpace);
                    if (pdCS != null)
                    {
                        cs = ColorSpaces.valueOf(pdCS.getName());
                        PreflightConfiguration cfg = context.getConfig();
                        ColorSpaceHelperFactory csFact = cfg.getColorSpaceHelperFact();
                        csHelper = csFact.getColorSpaceHelper(context, pdCS, ColorSpaceRestriction.ONLY_DEVICE);
                    }
                }

                if (cs == null)
                {
                    registerError("The ColorSpace is unknown", ERROR_GRAPHIC_UNEXPECTED_VALUE_FOR_KEY);
                    return;
                }
            }

            if (csHelper == null)
            {
                PDColorSpace pdCS = PDColorSpaceFactory.createColorSpace(csInlinedBase);
                PreflightConfiguration cfg = context.getConfig();
                ColorSpaceHelperFactory csFact = cfg.getColorSpaceHelperFact();
                csHelper = csFact.getColorSpaceHelper(context, pdCS, ColorSpaceRestriction.ONLY_DEVICE);
            }

            csHelper.validate();
        }
    }
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.