Package com.sun.pdfview

Examples of com.sun.pdfview.PDFParseException


  public void parse(PDFObject shaderObj) throws IOException
    {
        // read the axis coordinates (required)
        PDFObject coordsObj = shaderObj.getDictRef("Coords");
        if (coordsObj == null) {
            throw new PDFParseException("No coordinates found!");
        }
        PDFObject[] coords = coordsObj.getArray();
        center1 = new Point2D.Float(coords[0].getFloatValue(),
                                          coords[1].getFloatValue());
        center2 = new Point2D.Float(coords[3].getFloatValue(),
                                          coords[4].getFloatValue());
        radius1 = coords[2].getFloatValue();
        radius2 = coords[5].getFloatValue();
       
        // read the domain (optional)
        PDFObject domainObj = shaderObj.getDictRef("Domain");
        if (domainObj != null) {
            PDFObject[] domain = domainObj.getArray();
            setMinT(domain[0].getFloatValue());
            setMaxT(domain[1].getFloatValue());
        }
       
        // read the functions (required)
        PDFObject functionObj = shaderObj.getDictRef("Function");
        if (functionObj == null) {
            throw new PDFParseException("No function defined for shader!");
        }
        PDFObject[] functionArray = functionObj.getArray();
        PDFFunction[] functions = new PDFFunction[functionArray.length];
        for (int i = 0; i < functions.length; i++) {
            functions[i] = PDFFunction.getFunction(functionArray[i]);
View Full Code Here


            five[i] = nextChar();
            if (five[i] == '~') {
                if (nextChar() == '>') {
                    break;
                } else {
                    throw new PDFParseException("Bad character in ASCII85Decode: not ~>");
                }
            } else if (five[i] >= '!' && five[i] <= 'u') {
                five[i] -= '!';
            } else if (five[i] == 'z') {
                if (i == 0) {
                    five[i] = 0;
                    i = 4;
                } else {
                    throw new PDFParseException("Inappropriate 'z' in ASCII85Decode");
                }
            } else {
                throw new PDFParseException("Bad character in ASCII85Decode: " + five[i] + " (" + (char) five[i] + ")");
            }
        }

        if (i > 0) {
            i -= 1;
View Full Code Here

          target.setTargetDictionary(subTargetDictionary);
        }
      }
    } else {
      if (this.file == null) {
        throw new PDFParseException("No target dictionary in GoToE action " + targetObj);
      }
    }
    return target;
  }
View Full Code Here

            case 14:
            case 15:
                predictor = new PNGPredictor();
                break;
            default:
                throw new PDFParseException("Unknown predictor: " + algorithm);
        }
       
        // read the colors (optional)
        PDFObject colorsObj = params.getDictRef("Colors");
        if (colorsObj != null) {
View Full Code Here

          return getColorSpace(COLORSPACE_RGB);
        } else if(name.equals("DeviceCMYK")) {
          return getColorSpace(COLORSPACE_CMYK);
        } else {         
          // removed access to ary[1] dur to index out of bounds exceptions
            throw new PDFParseException("Unknown color space: " + name);
        }

        csobj.setCache(value);

        return value;
View Full Code Here

            byte[] fontdata = ttf.getStream ();

            try {
                setFont (fontdata);
            } catch (FontFormatException ffe) {
                throw new PDFParseException ("Font format exception: " + ffe);
            }
        } else {
            int flags = descriptor.getFlags ();
            int style = ((flags & PDFFontDescriptor.FORCEBOLD) != 0) ? Font.BOLD : Font.PLAIN;
View Full Code Here

    @Override
  protected void parse(PDFObject obj) throws IOException {
        // read the Functions array (required)
        PDFObject functionsObj = obj.getDictRef("Functions");
        if (functionsObj == null) {
            throw new PDFParseException("Functions required for function type 3!");
        }
        PDFObject[] functionsAry = functionsObj.getArray();
        functions = new PDFFunction[functionsAry.length];
        for (int i = 0; i < functionsAry.length; i++) {
          functions[i] = PDFFunction.getFunction(functionsAry[i]);
        }
       
        // read the Bounds array (required)
        PDFObject boundsObj = obj.getDictRef("Bounds");
        if (boundsObj == null) {
            throw new PDFParseException("Bounds required for function type 3!");
        }
        PDFObject[] boundsAry = boundsObj.getArray();
        bounds = new float[boundsAry.length + 2];
        if (bounds.length - 2 != functions.length - 1) {
          throw new PDFParseException("Bounds array must be of length " + (functions.length - 1));
        }
       
        for (int i = 0; i < boundsAry.length; i++) {
            bounds[i+1] = boundsAry[i].getFloatValue();
        }
        bounds[0] = getDomain(0);
        bounds[bounds.length-1] = getDomain(1);

        // read the encode array (required)
        PDFObject encodeObj = obj.getDictRef("Encode");
        if (encodeObj == null) {
            throw new PDFParseException("Encode required for function type 3!");
        }
        PDFObject[] encodeAry = encodeObj.getArray();
        encode = new float[encodeAry.length];
        if (encode.length != 2*functions.length) {
          throw new PDFParseException("Encode array must be of length " + 2*functions.length);
        }
        for (int i = 0; i < encodeAry.length; i++) {
            encode[i] = encodeAry[i].getFloatValue();
        }
    }
View Full Code Here

  protected void parse(PDFObject obj) throws IOException
    {
        // read the exponent (required)
        PDFObject nObj = obj.getDictRef("N");
        if (nObj == null) {
            throw new PDFParseException("Exponent required for function type 2!");
        }
        setN(nObj.getFloatValue());
       
        // read the zeros array (optional)
        PDFObject cZeroObj = obj.getDictRef("C0");
View Full Code Here

    @Override
  protected void parse(PDFObject obj) throws IOException {
        // read the size array (required)
        PDFObject sizeObj = obj.getDictRef("Size");
        if (sizeObj == null) {
            throw new PDFParseException("Size required for function type 0!");
        }
        PDFObject[] sizeAry = sizeObj.getArray();
        int[] size = new int[sizeAry.length];
        for (int i = 0; i < sizeAry.length; i++) {
            size[i] = sizeAry[i].getIntValue();
        }
        setSize(size);
   
        // read the # bits per sample (required)
        PDFObject bpsObj = obj.getDictRef("BitsPerSample");
        if (bpsObj == null) {
            throw new PDFParseException("BitsPerSample required for function type 0!");
        }
        setBitsPerSample(bpsObj.getIntValue());
       
        // read the order (optional)
        PDFObject orderObj = obj.getDictRef("Order");
View Full Code Here

        float[] range = null;

        // read the function type (required)
        PDFObject typeObj = obj.getDictRef ("FunctionType");
        if (typeObj == null) {
            throw new PDFParseException (
                    "No FunctionType specified in function!");
        }
        type = typeObj.getIntValue ();

        // read the function's domain (required)
        PDFObject domainObj = obj.getDictRef ("Domain");
        if (domainObj == null) {
            throw new PDFParseException ("No Domain specified in function!");
        }

        PDFObject[] domainAry = domainObj.getArray ();
        domain = new float[domainAry.length];
        for (int i = 0; i < domainAry.length; i++) {
            domain[i] = domainAry[i].getFloatValue ();
        }

        // read the function's range (optional)
        PDFObject rangeObj = obj.getDictRef ("Range");
        if (rangeObj != null) {
            PDFObject[] rangeAry = rangeObj.getArray ();
            range = new float[rangeAry.length];
            for (int i = 0; i < rangeAry.length; i++) {
                range[i] = rangeAry[i].getFloatValue ();
            }
        }

        // now create the acual function object
        switch (type) {
            case TYPE_0:
                if (rangeObj == null) {
                    throw new PDFParseException (
                            "No Range specified in Type 0 Function!");
                }
                function = new FunctionType0 ();
                break;
            case TYPE_2:
                function = new FunctionType2 ();
                break;
            case TYPE_3:
                function = new FunctionType3 ();
                break;
            case TYPE_4:
                if (rangeObj == null) {
                    throw new PDFParseException (
                            "No Range specified in Type 4 Function!");
                }
                function = new FunctionType4 ();
                break;
            default:
                throw new PDFParseException (
                        "Unsupported function type: " + type);
        }

        // fill in the domain and optionally the range
        function.setDomain (domain);
View Full Code Here

TOP

Related Classes of com.sun.pdfview.PDFParseException

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.