Examples of PreflightContext


Examples of org.apache.pdfbox.preflight.PreflightContext

    /**
     * Create a validation context. This context is set to the PreflightDocument.
     */
    protected void createContext()
    {
        this.ctx = new PreflightContext(this.originalDocument);
        ctx.setDocument(preflightDocument);
        preflightDocument.setContext(ctx);
        ctx.setXrefTableResolver(xrefTrailerResolver);
    }
View Full Code Here

Examples of org.apache.pdfbox.preflight.PreflightContext

    protected PreflightContext createContext() throws Exception
    {
        DataSource ds = new FileDataSource("src/test/resources/pdfa-with-annotations-square.pdf");
        PDDocument doc = PDDocument.load(ds.getInputStream());
        PreflightDocument preflightDocument = new PreflightDocument(doc.getDocument(), Format.PDF_A1B);
        PreflightContext ctx = new PreflightContext(ds);
        ctx.setDocument(preflightDocument);
        preflightDocument.setContext(ctx);
        return ctx;
    }
View Full Code Here

Examples of org.apache.pdfbox.preflight.PreflightContext

    }

    protected void valid(COSDictionary action, boolean valid, String expectedCode) throws Exception
    {
        ActionManagerFactory fact = new ActionManagerFactory();
        PreflightContext ctx = createContext();
        COSDictionary dict = new COSDictionary();
        dict.setItem(COSName.A, action);

        // process the action validation
        List<AbstractActionManager> actions = fact.getActionManagers(ctx, dict);
        for (AbstractActionManager abstractActionManager : actions)
        {
            abstractActionManager.valid();
        }

        // check the result
        if (!valid)
        {
            List<ValidationError> errors = ctx.getDocument().getResult().getErrorsList();
            assertFalse(errors.isEmpty());
            if (expectedCode != null || !"".equals(expectedCode))
            {
                boolean found = false;
                for (ValidationError err : errors)
                {
                    if (err.getErrorCode().equals(expectedCode))
                    {
                        found = true;
                        break;
                    }
                }
                assertTrue(found);
            }
        }
        else
        {
            if (ctx.getDocument().getResult() != null)
            {
                List<ValidationError> errors = ctx.getDocument().getResult().getErrorsList();
                assertTrue(errors.isEmpty());
            }
        }
    }
View Full Code Here

Examples of org.apache.pdfbox.preflight.PreflightContext

    /**
     * Create a validation context. This context is set to the PreflightDocument.
     */
    protected void createContext()
    {
        this.ctx = new PreflightContext(this.originalDocument);
        ctx.setDocument(preflightDocument);
        preflightDocument.setContext(ctx);
        ctx.setXrefTableResolver(xrefTrailerResolver);
    }
View Full Code Here

Examples of org.apache.pdfbox.preflight.PreflightContext

    protected PreflightContext createContext() throws Exception
    {
        DataSource ds = new FileDataSource("src/test/resources/pdfa-with-annotations-square.pdf");
        PDDocument doc = PDDocument.load(ds.getInputStream());
        PreflightDocument preflightDocument = new PreflightDocument(doc.getDocument(), Format.PDF_A1B);
        PreflightContext ctx = new PreflightContext(ds);
        ctx.setDocument(preflightDocument);
        preflightDocument.setContext(ctx);
        return ctx;
    }
View Full Code Here

Examples of org.apache.pdfbox.preflight.PreflightContext

    }

    protected void valid(COSDictionary action, boolean valid, String expectedCode) throws Exception
    {
        ActionManagerFactory fact = new ActionManagerFactory();
        PreflightContext ctx = createContext();
        COSDictionary dict = new COSDictionary();
        dict.setItem(COSName.A, action);

        // process the action validation
        List<AbstractActionManager> actions = fact.getActionManagers(ctx, dict);
        for (AbstractActionManager abstractActionManager : actions)
        {
            abstractActionManager.valid();
        }

        // check the result
        if (!valid)
        {
            List<ValidationError> errors = ctx.getDocument().getResult().getErrorsList();
            assertFalse(errors.isEmpty());
            if (expectedCode != null || !"".equals(expectedCode))
            {
                boolean found = false;
                for (ValidationError err : errors)
                {
                    if (err.getErrorCode().equals(expectedCode))
                    {
                        found = true;
                        break;
                    }
                }
                assertTrue(found);
            }
        }
        else
        {
            if (ctx.getDocument().getResult() != null)
            {
                List<ValidationError> errors = ctx.getDocument().getResult().getErrorsList();
                assertTrue(errors.isEmpty());
            }
        }
    }
View Full Code Here

Examples of org.apache.pdfbox.preflight.PreflightContext

    protected PreflightContext createContext() throws Exception
    {
        DataSource ds = new FileDataSource("src/test/resources/pdfa-with-annotations-square.pdf");
        PDDocument doc = PDDocument.load(ds.getInputStream());
        PreflightDocument preflightDocument = new PreflightDocument(doc.getDocument(), Format.PDF_A1B);
        PreflightContext ctx = new PreflightContext(ds);
        ctx.setDocument(preflightDocument);
        preflightDocument.setContext(ctx);
        return ctx;
    }
View Full Code Here

Examples of org.apache.pdfbox.preflight.PreflightContext

    }

    protected void valid(COSDictionary action, boolean valid, String expectedCode) throws Exception
    {
        ActionManagerFactory fact = new ActionManagerFactory();
        PreflightContext ctx = createContext();
        COSDictionary dict = new COSDictionary();
        dict.setItem(COSName.A, action);

        // process the action validation
        List<AbstractActionManager> actions = fact.getActionManagers(ctx, dict);
        for (AbstractActionManager abstractActionManager : actions)
        {
            abstractActionManager.valid();
        }

        // check the result
        if (!valid)
        {
            List<ValidationError> errors = ctx.getDocument().getResult().getErrorsList();
            assertFalse(errors.isEmpty());
            if (expectedCode != null || !"".equals(expectedCode))
            {
                boolean found = false;
                for (ValidationError err : errors)
                {
                    if (err.getErrorCode().equals(expectedCode))
                    {
                        found = true;
                        break;
                    }
                }
                assertTrue(found);
            }
        }
        else
        {
            if (ctx.getDocument().getResult() != null)
            {
                List<ValidationError> errors = ctx.getDocument().getResult().getErrorsList();
                assertTrue(errors.isEmpty());
            }
        }
    }
View Full Code Here

Examples of org.apache.pdfbox.preflight.PreflightContext

    /**
     * Create a validation context. This context is set to the PreflightDocument.
     */
    protected void createContext()
    {
        this.ctx = new PreflightContext(this.originalDocument);
        ctx.setDocument(preflightDocument);
        preflightDocument.setContext(ctx);
        ctx.setXrefTableResolver(xrefTrailerResolver);
    }
View Full Code Here

Examples of org.apache.pdfbox.preflight.PreflightContext

    /**
     * Create a validation context. This context is set to the PreflightDocument.
     */
    protected void createContext()
    {
        this.ctx = new PreflightContext(this.originalDocument);
        ctx.setDocument(preflightDocument);
        preflightDocument.setContext(ctx);
        ctx.setXrefTableResolver(xrefTrailerResolver);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.