Package org.apache.pdfbox.preflight.exception

Examples of org.apache.pdfbox.preflight.exception.ValidationException


                {
                    COSBase gsBase = extGStates.getItem(key);
                    COSDictionary gsDict = COSUtils.getAsDictionary(gsBase, cosDocument);
                    if (gsDict == null)
                    {
                        throw new ValidationException("The Extended Graphics State dictionary is invalid");
                    }
                    listOfExtGState.add(gsDict);
                }
            }
        }
View Full Code Here


    public void validate(PreflightContext context) throws ValidationException
    {
        PreflightPath vPath = context.getValidationPath();
        if (vPath.isEmpty() || !vPath.isExpectedType(COSDictionary.class))
        {
            throw new ValidationException("Annotation validation process needs at least one COSDictionary object");
        }

        COSDictionary annotDict = (COSDictionary) vPath.peek();

        PreflightConfiguration config = context.getConfig();
View Full Code Here

                {
                    exploreFields(ctx, acroForm.getFields());
                }
                catch (IOException e)
                {
                    throw new ValidationException("Unable to get the list of fields : " + e.getMessage(), e);
                }
            }
        }
        else
        {
            throw new ValidationException("There are no Catalog entry in the Document.");
        }
    }
View Full Code Here

                validatePage(context, (PDPage) pages.get(i));
            }
        }
        else
        {
            throw new ValidationException("There are no Catalog entry in the Document.");
        }
    }
View Full Code Here

        COSDictionary groupDictionary = COSUtils.getAsDictionary(baseGroup, cosDocument);
        if (groupDictionary != null)
        {
            if (!XOBJECT_DICTIONARY_KEY_GROUP.equals(groupDictionary.getNameAsString(COSName.TYPE)))
            {
                throw new ValidationException("The Group dictionary hasn't Group as Type value");
            }

            String sVal = groupDictionary.getNameAsString(COSName.S);
            if (sVal == null || XOBJECT_DICTIONARY_VALUE_S_TRANSPARENCY.equals(sVal))
            {
View Full Code Here

    public void validate(PreflightContext context) throws ValidationException
    {
        PreflightPath vPath = context.getValidationPath();
        if (vPath.isEmpty() && !vPath.isExpectedType(PDResources.class))
        {
            throw new ValidationException("ShadingPattern validation required at least a PDResources");
        }

        PDShadingResources shaddingResource = (PDShadingResources) vPath.peek();
        PDPage page = vPath.getClosestPathElement(PDPage.class);
        checkColorSpace(context, page, shaddingResource);
View Full Code Here

                while (skipped != offset)
                {
                    long curSkip = ra.skip(offset - skipped);
                    if (curSkip < 0)
                    {
                        throw new ValidationException("Unable to skip bytes in the PDFFile to check stream length");
                    }
                    skipped += curSkip;
                }

                // ---- go to the stream key word
                if (readUntilStream(ra))
                {
                    int c = ra.read();
                    if (c == '\r')
                    {
                        ra.read();
                    } // else c is '\n' no more character to read

                    // ---- Here is the true beginning of the Stream Content.
                    // ---- Read the given length of bytes and check the 10 next bytes
                    // ---- to see if there are endstream.
                    byte[] buffer = new byte[1024];
                    int nbBytesToRead = length;

                    do
                    {
                        int cr = 0;
                        if (nbBytesToRead > 1024)
                        {
                            cr = ra.read(buffer, 0, 1024);
                        }
                        else
                        {
                            cr = ra.read(buffer, 0, nbBytesToRead);
                        }
                        if (cr == -1)
                        {
                            addValidationError(context, new ValidationError(ERROR_SYNTAX_STREAM_LENGTH_INVALID,
                                    "Stream length is invalide"));
                            return;
                        }
                        else
                        {
                            nbBytesToRead = nbBytesToRead - cr;
                        }
                    } while (nbBytesToRead > 0);

                    int len = "endstream".length() + 2;
                    byte[] buffer2 = new byte[len];
                    for (int i = 0; i < len; ++i)
                    {
                        buffer2[i] = (byte) ra.read();
                    }

                    // ---- check the content of 10 last characters
                    String endStream = new String(buffer2);
                    if (buffer2[0] == '\r' && buffer2[1] == '\n')
                    {
                        if (!endStream.contains("endstream"))
                        {
                            addValidationError(context, new ValidationError(ERROR_SYNTAX_STREAM_LENGTH_INVALID,
                                    "Stream length is invalide"));
                        }
                    }
                    else if (buffer2[0] == '\r' && buffer2[1] == 'e')
                    {
                        if (!endStream.contains("endstream"))
                        {
                            addValidationError(context, new ValidationError(ERROR_SYNTAX_STREAM_LENGTH_INVALID,
                                    "Stream length is invalide"));
                        }
                    }
                    else if (buffer2[0] == '\n' && buffer2[1] == 'e')
                    {
                        if (!endStream.contains("endstream"))
                        {
                            addValidationError(context, new ValidationError(ERROR_SYNTAX_STREAM_LENGTH_INVALID,
                                    "Stream length is invalide"));
                        }
                    }
                    else
                    {
                        addValidationError(context, new ValidationError(ERROR_SYNTAX_STREAM_LENGTH_INVALID,
                                "Stream length is invalide"));
                    }

                }
                else
                {
                    addValidationError(context, new ValidationError(ERROR_SYNTAX_STREAM_LENGTH_INVALID,
                            "Stream length is invalide"));
                }
            }
        }
        catch (IOException e)
        {
            throw new ValidationException("Unable to read a stream to validate it due to : " + e.getMessage(), e);
        }
        finally
        {
            if (ra != null)
            {
View Full Code Here

    public void validate(PreflightContext context) throws ValidationException
    {
        PreflightPath vPath = context.getValidationPath();
        if (vPath.isEmpty() || !vPath.isExpectedType(COSDictionary.class))
        {
            throw new ValidationException("Action validation process needs at least one COSDictionary object");
        }

        COSDictionary actionsDict = (COSDictionary) vPath.peek();
        // AA entry is authorized only for Page, in this case A Page is just before the Action Dictionary in the path
        boolean aaEntryAuth = ((vPath.size() - vPath.getClosestTypePosition(PDPage.class)) == 2);
View Full Code Here

    public void validate(PreflightContext context) throws ValidationException
    {
        PreflightPath vPath = context.getValidationPath();
        if (vPath.isEmpty() && !vPath.isExpectedType(PDPage.class))
        {
            throw new ValidationException("Page validation required at least a PDPage");
        }

        PDPage page = (PDPage) vPath.peek();
        validateActions(context, page);
        validateAnnotation(context, page);
View Full Code Here

            if (e instanceof ValidationException)
            {
                throw (ValidationException) e;
            }
            // TODO IOException probably due to Encrypt
            throw new ValidationException("Unable to access Annotation", e);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.pdfbox.preflight.exception.ValidationException

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.