Package com.sun.pdfview

Examples of com.sun.pdfview.PDFObject


            throws IOException {
        super (baseFont, fontObj, descriptor);

        String fontName = descriptor.getFontName ();

        PDFObject ttf = descriptor.getFontFile2 ();
        if (ttf != null) {
            byte[] fontdata = ttf.getStream ();

            try {
                setFont (fontdata);
            } catch (FontFormatException ffe) {
                throw new PDFParseException ("Font format exception: " + ffe);
View Full Code Here


     * </li></p>
     */
    @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++) {
View Full Code Here

     */
    @Override
  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");
        if (cZeroObj != null) {
            PDFObject[] cZeroAry = cZeroObj.getArray();
            float[] cZero = new float[cZeroAry.length];
            for (int i = 0; i < cZeroAry.length; i++) {
                cZero[i] = cZeroAry[i].getFloatValue();
            }
            setC0(cZero);
        }
       
        // read the ones array (optional)
        PDFObject cOneObj = obj.getDictRef("C1");
        if (cOneObj != null) {
            PDFObject[] cOneAry = cOneObj.getArray();
            float[] cOne = new float[cOneAry.length];
            for (int i = 0; i < cOneAry.length; i++) {
                cOne[i] = cOneAry[i].getFloatValue();
            }
            setC1(cOne);
View Full Code Here

   
    /** Read the function information from a PDF Object */
    @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");
        if (orderObj != null) {
            setOrder(orderObj.getIntValue());
        }
       
        // read the encode array (optional)
        PDFObject encodeObj = obj.getDictRef("Encode");
        if (encodeObj != null) {
            PDFObject[] encodeAry = encodeObj.getArray();
            float[] encode = new float[encodeAry.length];
            for (int i = 0; i < encodeAry.length; i++) {
                encode[i] = encodeAry[i].getFloatValue();
            }
            setEncode(encode);
        }
       
        // read the decode array (optional)
        PDFObject decodeObj = obj.getDictRef("Decode");
        if (decodeObj != null) {
            PDFObject[] decodeAry = decodeObj.getArray();
            float[] decode = new float[decodeAry.length];
            for (int i = 0; i < decodeAry.length; i++) {
                decode[i] = decodeAry[i].getFloatValue();
            }
            setDecode(decode);
View Full Code Here

        int type;
        float[] domain = null;
        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 ();
            }
        }
View Full Code Here

    /** 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) {
            this.firstChar = firstCharObj.getIntValue();
        }
        if (lastCharObj != null) {
            this.lastChar = lastCharObj.getIntValue();
        }

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

            this.widths = new float[widthArray.length];

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

        if (resources != null) {
            this.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();
        }
        this.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) {
            this.rsrc.putAll(rsrcObj.getDictionary());
        }

        // get the character processes, indexed by name
        this.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) this.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(this.bbox, 0);
            page.addXform(this.at);

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

            float width = this.widths[src - this.firstChar];

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

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

        // figure out the base encoding, if one exists
        PDFObject baseEncObj = encoding.getDictRef("BaseEncoding");
        if (baseEncObj != null) {
            this.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

     */
    public Type1CFont (String baseFont, PDFObject src,
                       PDFFontDescriptor descriptor) throws IOException {
        super (baseFont, src, descriptor);

        PDFObject dataObj = descriptor.getFontFile3 ();
        this.data = dataObj.getStream ();
        this.pos = 0;
        parse ();

        // TODO: free up (set to null) unused structures (data, subrs, stack)
    }
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.