Package com.sun.pdfview

Examples of com.sun.pdfview.PDFObject


    /** Creates a new instance of OutlineFont */
    public OutlineFont(String baseFont, PDFObject fontObj,
            PDFFontDescriptor descriptor) throws IOException {
        super(baseFont, descriptor);

        PDFObject firstCharObj = fontObj.getDictRef("FirstChar");
        PDFObject lastCharObj = fontObj.getDictRef("LastChar");
        PDFObject widthArrayObj = fontObj.getDictRef("Widths");

        if (firstCharObj != null) {
            firstChar = firstCharObj.getIntValue();
        }
        if (lastCharObj != null) {
            lastChar = lastCharObj.getIntValue();
        }

        if (widthArrayObj != null) {
            PDFObject[] widthArray = widthArrayObj.getArray();

            widths = new float[widthArray.length];

            for (int i = 0; i < widthArray.length; i++) {
                widths[i] = widthArray[i].getFloatValue() / getDefaultWidth();
View Full Code Here


        if (resources != null) {
            rsrc.putAll(resources);
        }

        // get the transform matrix
        PDFObject matrix = fontObj.getDictRef("FontMatrix");
        float matrixAry[] = new float[6];
        for (int i = 0; i < 6; i++) {
            matrixAry[i] = matrix.getAt(i).getFloatValue();
        }
        at = new AffineTransform(matrixAry);

        // get the scale from the matrix
        float scale = matrixAry[0] + matrixAry[2];

        // put all the resources in a Hash
        PDFObject rsrcObj = fontObj.getDictRef("Resources");
        if (rsrcObj != null) {
            rsrc.putAll(rsrcObj.getDictionary());
        }

        // get the character processes, indexed by name
        charProcs = fontObj.getDictRef("CharProcs").getDictionary();
View Full Code Here

        if (name == null) {
            throw new IllegalArgumentException("Glyph name required for Type3 font!" +
                    "Source character: " + (int) src);
        }

        PDFObject pageObj = (PDFObject) charProcs.get(name);
        if (pageObj == null) {
            // glyph not found.  Return an empty glyph...
            return new PDFGlyph(src, name, new GeneralPath(), new Point2D.Float(0, 0));
        }

        try {
            PDFPage page = new PDFPage(bbox, 0);
            page.addXform(at);

            PDFParser prc = new PDFParser(page, pageObj.getStream(), rsrc);
            prc.go(true);

            float width = widths[src - firstChar];

            Point2D advance = new Point2D.Float(width, 0);
View Full Code Here

     */
    public void parseEncoding(PDFObject encoding) throws IOException {
        differences = new HashMap<Character,String>();

        // figure out the base encoding, if one exists
        PDFObject baseEncObj = encoding.getDictRef("BaseEncoding");
        if (baseEncObj != null) {
            baseEncoding = getBaseEncoding(baseEncObj.getStringValue());
        }

        // parse the differences array
        PDFObject diffArrayObj = encoding.getDictRef("Differences");
        if (diffArrayObj != null) {
            PDFObject[] diffArray = diffArrayObj.getArray();
            int curPosition = -1;

            for (int i = 0; i < diffArray.length; i++) {
                if (diffArray[i].getType() == PDFObject.NUMBER) {
                    curPosition = diffArray[i].getIntValue();
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++) {
    white[i]= ary.getAt(i).getFloatValue();
      }
  }
  ary= obj.getDictRef("BlackPoint");
  if (ary!=null) {
      for(int i=0; i<3; i++) {
    black[i]= ary.getAt(i).getFloatValue();
      }
  }
  ary= obj.getDictRef("Gamma");
  if (ary!=null) {
      for (int i=0; i<3; i++) {
    gamma[i]= ary.getAt(i).getFloatValue();
      }
  }
  ary= obj.getDictRef("Matrix");
  if (ary!=null) {
      for (int i=0; i<9; i++) {
    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++) {
    white[i]= ary.getAt(i).getFloatValue();
      }
  }
  ary= obj.getDictRef("BlackPoint");
  if (ary!=null) {
      for(int i=0; i<3; i++) {
    black[i]= ary.getAt(i).getFloatValue();
      }
  }
  ary= obj.getDictRef("Range");
  if (ary!=null) {
      for (int i=0; i<4; i++) {
    range[i]= ary.getAt(i).getFloatValue();
      }
  }
    }
View Full Code Here

        // the default components per pixel is 3
        int numComponents = 3;
       
        // see if we have a colorspace
        try {
            PDFObject csObj = dict.getDictRef("ColorSpace");
            if (csObj != null) {
                // we do, so get the number of components
                PDFColorSpace cs = PDFColorSpace.getColorSpace(csObj, null);
                numComponents = cs.getNumComponents();
            }
View Full Code Here

        String subType = obj.getDictRef("Subtype").getStringValue();
        if (subType == null) {
            subType = obj.getDictRef("S").getStringValue();
        }
        PDFObject baseFontObj = obj.getDictRef("BaseFont");
        PDFObject encodingObj = obj.getDictRef("Encoding");
        PDFObject descObj = obj.getDictRef("FontDescriptor");

        if (baseFontObj != null) {
            baseFont = baseFontObj.getStringValue();
        } else {
            baseFontObj = obj.getDictRef("Name");
View Full Code Here

        if (shader != null) {
            return shader;
        }
       
        // 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 FUNCTION_SHADING:
            case RADIAL_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)
        PDFObject bgObj = shaderObj.getDictRef("Background");
        if (bgObj != null) {
            PDFObject[] bgObjs = bgObj.getArray();
            float[] bgArray = new float[bgObjs.length];
            for (int i = 0; i < bgArray.length; i++) {
                bgArray[i] = bgObjs[i].getFloatValue();
            }
            PDFPaint paint = cs.getPaint(bgArray);
            shader.setBackground(paint);         
        }
       
        // read the bounding box (optional)
        PDFObject bboxObj = shaderObj.getDictRef("BBox");
        if (bboxObj != null) {
            shader.setBBox(PDFFile.parseNormalisedRectangle(bboxObj));
        }
       
        // parse the shader-specific attributes
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)) {
            cidToGidMap = mapObj.getStreamBuffer();
        }
    }
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.