Package com.sun.pdfview

Examples of com.sun.pdfview.PDFObject


                    PDFFontDescriptor descriptor, File fontFile)
            throws IOException {
        super (baseFont, fontObj, descriptor);

        String fontName = descriptor.getFontName ();
        PDFObject ttfObj = descriptor.getFontFile2 ();

        // try {
        //    byte[] fontData = ttfObj.getStream();
        //    java.io.FileOutputStream fis = new java.io.FileOutputStream("/tmp/" + fontName + ".ttf");
        //    fis.write(fontData);
        //    fis.flush();
        //    fis.close();
        // } catch (Exception ex) {
        //    ex.printStackTrace();
        // }
        if (ttfObj != null || fontFile != null) {
            if (ttfObj != null) {
                font = TrueTypeFont.parseFont (ttfObj.getStreamBuffer ());
            } else {
                final RandomAccessFile raFile = fontFile != null ? new RandomAccessFile(fontFile, "r") : null;
                final FileChannel fc = raFile.getChannel();
                try {
                    MappedByteBuffer mappedFont = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
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

   * @param fontObj
   * @throws IOException
   ************************************************************************/
 
  public void parseToUnicodeMap(PDFObject fontObj) throws IOException {
    PDFObject toUnicode = fontObj.getDictRef("ToUnicode");
    if (toUnicode != null) {
      PDFCMap cmap = PDFCMap.getCMap(toUnicode);
      this.glyphLookupMap = cmap;
    }
  }
View Full Code Here

            throw new PDFParseException("Type 3 function only accepts a " +
                    "single input, so Domain should have just 2 elements");
        }

        // 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]);
        }

        int k = functions.length;
        PDFObject domainObj = obj.getDictRef("Domain");
        if (domainObj == null) {
            throw new PDFParseException("domain required for function type 3!");
        }
       
        // 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();
        if (boundsAry.length != k - 1) {
            throw new PDFParseException("Bounds array length " +
                    boundsAry.length + " should be " + (k - 1) +
                    " with functions array length " +
                    functions.length);
        }
        bounds = new float[boundsAry.length];
        for (int i = 0; i < boundsAry.length; i++) {
            bounds[i] = boundsAry[i].getFloatValue();
        }

        // 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();
        if (encodeAry.length != 2 * k) {
            throw new PDFParseException("There should be " + (2 * k) +
                    " values in Encode for the given number of functions.");
        }
        encode = new float[encodeAry.length];
View Full Code Here

     * Read the zeros, ones and exponent
     */
    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 */
    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

                    PDFDestination dest = ((GoToAction) action).getDestination();
                    if (dest == null) {
                        return;
                    }

                    PDFObject page = dest.getPage();
                    if (page == null) {
                        return;
                    }

                    int pageNum = curFile.getPageNumber(page);
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.