Package com.sun.pdfview

Examples of com.sun.pdfview.PDFParseException


          }
    } else if (subType.equals("MMType1")) {
      // not yet implemented, fake it with a built-in font
      font = new BuiltinFont(baseFont, obj, descriptor);
        } else {
            throw new PDFParseException("Don't know how to handle a '" +
                    subType + "' font");
        }

        font.setSubtype(subType);
        font.setEncoding(encoding);
View Full Code Here


     * and the <b>Bounds</b> array to the domain of the corresponding function.
     * </li></p>
     */
    protected void parse(PDFObject obj) throws IOException {       
        if (getNumInputs() != 1) {
            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];
        for (int i = 0; i < encodeAry.length; i++) {
            encode[i] = encodeAry[i].getFloatValue();
View Full Code Here

    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");
View Full Code Here

    public ByteBuffer decryptBuffer(String cryptFilterName,
            PDFObject streamObj, ByteBuffer streamBuf)
            throws PDFParseException {

        if (cryptFilterName != null) {
            throw new PDFParseException("This Encryption version does not support Crypt filters");
        }

        return streamBuf;
    }
View Full Code Here

    /** Read the function information from a PDF Object */
    protected void parse(PDFObject obj) throws IOException {
        // read the postscript from the stream
        readPS(obj.getStreamBuffer());
        throw new PDFParseException("Unsupported function type 4.");
    }
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");
View Full Code Here

            }
        } catch (GeneralSecurityException e) {
            // Unexpected, as our test of JCE availability should have caught
            // problems with cipher availability.
            // It may well be a problem with document content?
            throw new PDFParseException("Unable to check passwords: " +
                    e.getMessage(), e);
        }

        if (generalKeyBytes == null) {
            throw new PDFAuthenticationFailureException(
View Full Code Here

    public ByteBuffer decryptBuffer(
            String cryptFilterName, PDFObject streamObj, ByteBuffer streamBuf)
            throws PDFParseException {

        if (cryptFilterName != null) {
            throw new PDFParseException(
                    "This encryption version does not support Crypt filters");
        }

        if (streamObj != null) {
            checkNums(streamObj.getObjNum(), streamObj.getObjGen());
View Full Code Here

        try {
            createAndInitialiseContentCipher(
                    ByteBuffer.wrap(junkBuffer),
                    junkKey);
        } catch (PDFParseException e) {
            throw new PDFParseException("Internal error; " +
                    "failed to produce test cipher: " + e.getMessage());
        } catch (NoSuchAlgorithmException e) {
            throw new EncryptionUnsupportedByPlatformException(
                    "JCE does not offer required cipher", e);
        } catch (NoSuchPaddingException e) {
View Full Code Here

        try {
            cipher = createAndInitialiseContentCipher(
                    encrypted, decryptionKeyBytes);
        } catch (GeneralSecurityException e) {
            // we should have caught this earlier in testCipherAvailability
            throw new PDFParseException(
                    "Unable to create cipher due to platform limitation: " +
                            e.getMessage(), e);
        }

        try {
            // the decrypted content will never be more than the encrypted
            // content. Thanks to padding, this buffer will be at most 16
            // bytes bigger than the encrypted content
            final ByteBuffer decryptedBuf =
                    ByteBuffer.allocate(encrypted.remaining());
            cipher.doFinal(encrypted, decryptedBuf);
            decryptedBuf.flip();
            return decryptedBuf;
        } catch (GeneralSecurityException e) {
            throw new PDFParseException(
                    "Could not decrypt: " + e.getMessage(), 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.