Package com.sun.pdfview

Examples of com.sun.pdfview.PDFObject


    return destination;
  }

  public static int getOptionFieldInt(PDFObject dict, String name, int defaultValue) throws IOException {

    PDFObject dictParams =  dict.getDictRef("DecodeParms");

    if (dictParams == null) {
      return defaultValue;
    }
    PDFObject value = dictParams.getDictRef(name);
    if (value == null) {
      return defaultValue;
    }
    return value.getIntValue();
  }
View Full Code Here


    return value.getIntValue();
  }

  public static boolean getOptionFieldBoolean(PDFObject dict, String name, boolean defaultValue) throws IOException {

    PDFObject dictParams =  dict.getDictRef("DecodeParms");

    if (dictParams == null) {
      return defaultValue;
    }
    PDFObject value = dictParams.getDictRef(name);
    if (value == null) {
      return defaultValue;
    }
    return value.getBooleanValue();
  }
View Full Code Here

       
        this.resources = patternObj.getDictRef("Resources").getDictionary();
        this.paintType = patternObj.getDictRef("PaintType").getIntValue();
        this.tilingType = patternObj.getDictRef("TilingType").getIntValue();
       
        PDFObject bboxObj = patternObj.getDictRef("BBox");
  this.bbox= new Rectangle2D.Float(bboxObj.getAt(0).getFloatValue(),
                                    bboxObj.getAt(1).getFloatValue(),
                                    bboxObj.getAt(2).getFloatValue(),
                                    bboxObj.getAt(3).getFloatValue());
       
        this.xStep = patternObj.getDictRef("XStep").getIntValue();
        this.yStep = patternObj.getDictRef("YStep").getIntValue();
    }
View Full Code Here

     */
    public static Predictor getPredictor(PDFObject params)
        throws IOException
    {
        // get the algorithm (required)
        PDFObject algorithmObj = params.getDictRef("Predictor");
        if (algorithmObj == null) {
            // no predictor
            return null;
        }
        int algorithm = algorithmObj.getIntValue();
   
        // create the predictor object
        Predictor predictor = null;
        switch (algorithm) {
            case 1:
                // no predictor
                return null;
            case 2:
              predictor = new TIFFPredictor();
            case 10:
            case 11:
            case 12:
            case 13:
            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) {
            predictor.setColors(colorsObj.getIntValue());
        }
       
        // read the bits per component (optional)
        PDFObject bpcObj = params.getDictRef("BitsPerComponent");
        if (bpcObj != null) {
            predictor.setBitsPerComponent(bpcObj.getIntValue());
        }
       
        // read the columns (optional)
        PDFObject columnsObj = params.getDictRef("Columns");
        if (columnsObj != null) {
            predictor.setColumns(columnsObj.getIntValue());
        }
       
        // all set
        return predictor;
    }
View Full Code Here

  // obj is a dictionary that has the following parts:
  // WhitePoint [a b c]
  // BlackPoint [a b c]
  // Gamma a
  super(TYPE_GRAY, 1);
  PDFObject ary= obj.getDictRef("WhitePoint");
  if (ary!=null) {
      for(int i=0; i<3; i++) {
    this.white[i]= ary.getAt(i).getFloatValue();
      }
  }
  ary= obj.getDictRef("BlackPoint");
  if (ary!=null) {
      for(int i=0; i<3; i++) {
    this.black[i]= ary.getAt(i).getFloatValue();
      }
  }
  PDFObject g= obj.getDictRef("Gamma");
  if (g!=null) {
      this.gamma= g.getFloatValue();
  }
    }
View Full Code Here

     */
    public static PDFColorSpace getColorSpace(PDFObject csobj, Map resources)
        throws IOException {
        String name;

        PDFObject colorSpaces = null;

        if (resources != null) {
            colorSpaces = (PDFObject) resources.get("ColorSpace");
        }

        if (csobj.getType() == PDFObject.NAME) {
            name = csobj.getStringValue();

            if (name.equals("DeviceGray") || name.equals("G")) {
                return getColorSpace(COLORSPACE_GRAY);
            } else if (name.equals("DeviceRGB") || name.equals("RGB")) {
                return getColorSpace(COLORSPACE_RGB);
            } else if (name.equals("DeviceCMYK") || name.equals("CMYK")) {
                return getColorSpace(COLORSPACE_CMYK);
            } else if (name.equals("Pattern")) {
                return getColorSpace(COLORSPACE_PATTERN);
            } else if (colorSpaces != null) {
                csobj = colorSpaces.getDictRef(name);
            }
        }

        if (csobj == null) {
            return null;
View Full Code Here

        // find out what what is according to the CIE color space
        // note that this is not reflexive (i.e. passing this value
        // into toRGB does not get you (1.0, 1.0, 1.0) back)
        // cieWhite = cieCS.fromRGB(new float[] { 1.0f, 1.0f, 1.0f } );
     
        PDFObject ary= obj.getDictRef("WhitePoint");
  if (ary!=null) {
      for(int i=0; i<3; i++) {
    this.white[i]= ary.getAt(i).getFloatValue();
      }
  }
  ary= obj.getDictRef("BlackPoint");
  if (ary!=null) {
      for(int i=0; i<3; i++) {
    this.black[i]= ary.getAt(i).getFloatValue();
      }
  }
  ary= obj.getDictRef("Gamma");
  if (ary!=null) {
      for (int i=0; i<3; i++) {
    this.gamma[i]= ary.getAt(i).getFloatValue();
      }
  }
  ary= obj.getDictRef("Matrix");
  if (ary!=null) {
      for (int i=0; i<9; i++) {
    this.matrix[i]= ary.getAt(i).getFloatValue();
      }
  }
       
        // create a scale matrix relative to the 50 CIE color space.
        // see http://www.brucelindbloom.com/Eqn_RGB_XYZ_Matrix.html
View Full Code Here

  // obj is a dictionary that has the following parts:
  // WhitePoint [a b c]
  // BlackPoint [a b c]
  // Gamma a
  super(TYPE_Lab, 3);
  PDFObject ary= obj.getDictRef("WhitePoint");
  if (ary!=null) {
      for(int i=0; i<3; i++) {
    this.white[i]= ary.getAt(i).getFloatValue();
      }
  }
  ary= obj.getDictRef("BlackPoint");
  if (ary!=null) {
      for(int i=0; i<3; i++) {
    this.black[i]= ary.getAt(i).getFloatValue();
      }
  }
  ary= obj.getDictRef("Range");
  if (ary!=null) {
      for (int i=0; i<4; i++) {
    this.range[i]= ary.getAt(i).getFloatValue();
      }
  }
    }
View Full Code Here

        super(baseName, fontObj, descriptor);

        parseWidths(fontObj);

        // read the CIDSystemInfo dictionary (required)
        PDFObject systemInfoObj = fontObj.getDictRef("CIDSystemInfo");
        // read the cid to gid map (optional)
        PDFObject mapObj = fontObj.getDictRef("CIDToGIDMap");


        // only read the map if it is a stream (if it is a name, it
        // is "Identity" and can be ignored
        if (mapObj != null && (mapObj.getType() == PDFObject.STREAM)) {
            this.cidToGidMap = mapObj.getStreamBuffer();
        }
    }
View Full Code Here

    /** Parse the Widths array and DW object */
    private void parseWidths(PDFObject fontObj)
            throws IOException {
        // read the default width (otpional)
        PDFObject defaultWidthObj = fontObj.getDictRef("DW");
        if (defaultWidthObj != null && defaultWidthObj.getIntValue() != 0) {
          // XOND: commented out the setting of new default width, as several
          //    PDFs are displayed in a wrong format due to this:
//            this.defaultWidth = defaultWidthObj.getIntValue();
        }
       
        int entryIdx = 0;
        int first = 0;
        int last = 0;
        PDFObject[] widthArray;

        // read the widths table
        PDFObject widthObj = fontObj.getDictRef("W");
        if (widthObj != null) {

            // initialize the widths array
            this.widths = new HashMap<Character, Float>();

            // parse the width array
            widthArray = widthObj.getArray();

            /* an entry can be in one of two forms:
             *   <startIndex> <endIndex> <value> or
             *   <startIndex> [ array of values ]
             * we use the entryIdx to differentitate between them
             */
            for (int i = 0; i < widthArray.length; i++) {
                if (entryIdx == 0) {
                    // first value in an entry.  Just store it
                    first = widthArray[i].getIntValue();
                } else if (entryIdx == 1) {
                    // second value -- is it an int or array?
                    if (widthArray[i].getType() == PDFObject.ARRAY) {
                        // add all the entries in the array to the width array
                        PDFObject[] entries = widthArray[i].getArray();
                        for (int c = 0; c < entries.length; c++) {
                            Character key = Character.valueOf((char) (c + first));

                            // value is width / default width
                            float value = entries[c].getIntValue();
                            this.widths.put(key, new Float(value));
                        }
                        // all done
                        entryIdx = -1;
                    } else {
                        last = widthArray[i].getIntValue();
                    }
                } else {
                    // third value.  Set a range
                    int value = widthArray[i].getIntValue();

                    // set the range
                    for (int c = first; c <= last; c++) {
                        this.widths.put(Character.valueOf((char) c), new Float(value));
                    }

                    // all done
                    entryIdx = -1;
                }

                entryIdx++;
            }
        }

        // read the optional vertical default width
        defaultWidthObj = fontObj.getDictRef("DW2");
        if (defaultWidthObj != null) {
            this.defaultWidthVertical = defaultWidthObj.getIntValue();
        }

        // read the vertical widths table
        widthObj = fontObj.getDictRef("W2");
        if (widthObj != null) {

            // initialize the widths array
            this.widthsVertical = new HashMap<Character, Float>();

            // parse the width2 array
            widthArray = widthObj.getArray();

            /* an entry can be in one of two forms:
             *   <startIndex> <endIndex> <value> or
             *   <startIndex> [ array of values ]
             * we use the entryIdx to differentitate between them
View Full Code Here

TOP

Related Classes of com.sun.pdfview.PDFObject

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.