Package com.sun.pdfview

Examples of com.sun.pdfview.PDFParseException


   ************************************************************************/
  public static boolean parseBooleanFromDict(String key, PDFObject parent, boolean mandatory) throws IOException{
    PDFObject val = parent.getDictRef(key);
    if(val == null){
      if(mandatory){
        throw new PDFParseException(key + "value could not be parsed : " + parent.toString())
      }
      return false;
    }
    return val.getBooleanValue();
  }
View Full Code Here


   ************************************************************************/
  public static int parseIntegerFromDict(String key, PDFObject parent, boolean mandatory) throws IOException{
    PDFObject val = parent.getDictRef(key);
    if(val == null){
      if(mandatory){
        throw new PDFParseException(key + "value could not be parsed : " + parent.toString())
      }
      return 0;
    }
    return val.getIntValue();
  }
View Full Code Here

   ************************************************************************/
  public static PDFDestination parseDestination(String key, PDFObject parent, PDFObject root, boolean mandatory) throws IOException{
    PDFObject destObj = parent.getDictRef(key);
    if (destObj == null) {
      if(mandatory){
        throw new PDFParseException("Error parsing destination " + parent);
      }
      return null;
    }
    return PDFDestination.getDestination(destObj, root);

View Full Code Here

        throws IOException
    {
        // figure out the action type
        PDFObject typeObj = obj.getDictRef("S");
        if (typeObj == null) {
            throw new PDFParseException("No action type in object: " + obj);
        }
       
        // create the action based on the type
        PDFAction action = null;
        String type = typeObj.getStringValue();
        if (type.equals("GoTo")) {
            action = new GoToAction(obj, root);
        }else if(type.equals("GoToE")){
          action = new GoToEAction(obj, root);
        }else if(type.equals("GoToR")){
          action = new GoToRAction(obj, root);
        }else if(type.equals("URI")){
          action = new UriAction(obj, root);
        }else if(type.equals("Launch")){
          action = new LaunchAction(obj, root);
        }
        else {
            /** [JK FIXME: Implement other action types! ] */
            throw new PDFParseException("Unknown Action type: " + type);
        }
       
        // figure out if there is a next action
        PDFObject nextObj = obj.getDictRef("Next");
        if (nextObj != null) {
View Full Code Here

        }
       
        // read the type (required)
        PDFObject typeObj = shaderObj.getDictRef("ShadingType");
        if (typeObj == null) {
            throw new PDFParseException("No shader type defined!");
        }
        int type = typeObj.getIntValue();
       
        // create the shader
        switch (type) {
            case AXIAL_SHADING:
                shader = new ShaderType2();
                break;
   
            case RADIAL_SHADING:
              shader = new ShaderType3();
              break;

            case FUNCTION_SHADING:
            case FREE_FORM_SHADING:
            case LATTICE_SHADING:
            case COONS_PATCH_MESH_SHADING:
            case TENSOR_PRODUCTS_MESH_SHADING:
            default:   
                throw new PDFParseException("Unsupported shader type: " + type);
        }
       
        // read the color space (required)
        PDFObject csObj = shaderObj.getDictRef("ColorSpace");
        if (csObj == null) {
            throw new PDFParseException("No colorspace defined!");
        }
        PDFColorSpace cs = PDFColorSpace.getColorSpace(csObj, resources);
        shader.setColorSpace(cs);
       
        // read the background color (optional)
View Full Code Here

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        while (true) {
            int pW = cW;
            cW = nextCode();
            if (cW == -1) {
                throw new PDFParseException("Missed the stop code in LZWDecode!");
            }
            if (cW == STOP) {
                break;
            } else if (cW == CLEARDICT) {
                resetDict();
View Full Code Here

  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();
        Point2D start = new Point2D.Float(coords[0].getFloatValue(),
                                          coords[1].getFloatValue());
        Point2D end   = new Point2D.Float(coords[2].getFloatValue(),
                                          coords[3].getFloatValue());
        setAxisStart(start);
        setAxisEnd(end);
       
        // 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

                    }
                    streamBuf = dict.getDecrypter().decryptBuffer(cfName, null, streamBuf);
                } else if (enctype.equals("JBIG2Decode")) {
                    streamBuf = JBig2Decode.decode(dict, streamBuf, spec.params[i]);
                } else {
                    throw new PDFParseException("Unknown coding method:" + spec.ary[i].getStringValue());
                }
            }
        }

        return streamBuf;
View Full Code Here

                break;
            case 2:
              pattern = new PatternType2();
              break;
            default:
                throw new PDFParseException("Unknown pattern type " + type);
        }      
       
        // set the transform
        pattern.setTransform(xform);
       
View Full Code Here

    try {
      byte[] input = new byte[buf.remaining()];
      buf.get(input);
      Iterator<ImageReader> readers = ImageIO.getImageReadersByMIMEType("image/jpeg2000");
      if (readers.hasNext() == false) {
        throw new PDFParseException("JPXDecode failed. No reader available");
      }
      ImageReader reader = readers.next();
      reader.setInput(new MemoryCacheImageInputStream(new ByteArrayInputStream(input)));
      BufferedImage bimg = reader.read(0);
      return bimg;
    } catch (IOException e) {
            throw new PDFParseException("JPXDecode failed", e);
    }

  }
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.