Package org.apache.pdfbox.util

Examples of org.apache.pdfbox.util.Overlay


    public static void main(final String[] args) throws Exception
    {
        // suppress the Dock icon on OS X
        System.setProperty("apple.awt.UIElement", "true");

        Overlay overlayer = new Overlay();
        Map<Integer, String> specificPageOverlayFile = new HashMap<Integer, String>();
        boolean useNonSeqParser = false;
        // input arguments
        for (int i = 0; i < args.length; i++)
        {
            String arg = args[i].trim();
            if (i == 0)
            {
                overlayer.setInputFile(arg);
            }
            else if (i == (args.length - 1))
            {
                overlayer.setOutputFile(arg);
            }
            else if (arg.equals(POSITION) && ((i + 1) < args.length))
            {
                if (Position.FOREGROUND.toString().equalsIgnoreCase(args[i + 1].trim()))
                {
                    overlayer.setOverlayPosition(Position.FOREGROUND);
                }
                else if (Position.BACKGROUND.toString().equalsIgnoreCase(args[i + 1].trim()))
                {
                    overlayer.setOverlayPosition(Position.BACKGROUND);
                }
                else
                {
                    usage();
                }
                i += 1;
            }
            else if (arg.equals(ODD) && ((i + 1) < args.length))
            {
                overlayer.setOddPageOverlayFile(args[i + 1].trim());
                i += 1;
            }
            else if (arg.equals(EVEN) && ((i + 1) < args.length))
            {
                overlayer.setEvenPageOverlayFile(args[i + 1].trim());
                i += 1;
            }
            else if (arg.equals(FIRST) && ((i + 1) < args.length))
            {
                overlayer.setFirstPageOverlayFile(args[i + 1].trim());
                i += 1;
            }
            else if (arg.equals(LAST) && ((i + 1) < args.length))
            {
                overlayer.setLastPageOverlayFile(args[i + 1].trim());
                i += 1;
            }
            else if (arg.equals(USEALLPAGES) && ((i + 1) < args.length))
            {
                overlayer.setAllPagesOverlayFile(args[i + 1].trim());
                i += 1;
            }
            else if (arg.equals(PAGE) && ((i + 2) < args.length) && (isInteger(args[i + 1].trim())))
            {
                specificPageOverlayFile.put(Integer.parseInt(args[i + 1].trim()), args[i + 2].trim());
                i += 2;
            }
            else if( args[i].equals( NONSEQ ) )
            {
                useNonSeqParser = true;
            }
            else if (overlayer.getDefaultOverlayFile() == null)
            {
                overlayer.setDefaultOverlayFile(arg);
            }
            else
            {
                usage();
            }
        }
       
        if (overlayer.getInputFile() == null || overlayer.getOutputFile() == null)
        {
            usage();
        }
       
        try
        {
            overlayer.overlay(specificPageOverlayFile,useNonSeqParser);
        }
        catch (Exception e)
        {
            LOG.error("Overlay failed: " + e.getMessage(), e);
            throw e;
View Full Code Here


     * @param args command line arguments
     * @throws Exception if something went wrong
     */
    public static void main(final String[] args) throws Exception
    {
        Overlay overlayer = new Overlay();
        Map<Integer, String> specificPageOverlayFile = new HashMap<Integer, String>();
        boolean useNonSeqParser = false;
        // input arguments
        for (int i = 0; i < args.length; i++)
        {
            String arg = args[i].trim();
            if (i == 0)
            {
                overlayer.setInputFile(arg);
            }
            else if (i == (args.length - 1))
            {
                overlayer.setOutputFile(arg);
            }
            else if (arg.equals(POSITION) && ((i + 1) < args.length))
            {
                if (Position.FOREGROUND.toString().equalsIgnoreCase(args[i + 1].trim()))
                {
                    overlayer.setOverlayPosition(Position.FOREGROUND);
                }
                else if (Position.BACKGROUND.toString().equalsIgnoreCase(args[i + 1].trim()))
                {
                    overlayer.setOverlayPosition(Position.BACKGROUND);
                }
                else
                {
                    usage();
                }
                i += 1;
            }
            else if (arg.equals(ODD) && ((i + 1) < args.length))
            {
                overlayer.setOddPageOverlayFile(args[i + 1].trim());
                i += 1;
            }
            else if (arg.equals(EVEN) && ((i + 1) < args.length))
            {
                overlayer.setEvenPageOverlayFile(args[i + 1].trim());
                i += 1;
            }
            else if (arg.equals(FIRST) && ((i + 1) < args.length))
            {
                overlayer.setFirstPageOverlayFile(args[i + 1].trim());
                i += 1;
            }
            else if (arg.equals(LAST) && ((i + 1) < args.length))
            {
                overlayer.setLastPageOverlayFile(args[i + 1].trim());
                i += 1;
            }
            else if (arg.equals(PAGE) && ((i + 2) < args.length) && (isInteger(args[i + 1].trim())))
            {
                specificPageOverlayFile.put(Integer.parseInt(args[i + 1].trim()), args[i + 2].trim());
                i += 2;
            }
            else if( args[i].equals( NONSEQ ) )
            {
                useNonSeqParser = true;
            }
            else if (overlayer.getDefaultOverlayFile() == null)
            {
                overlayer.setDefaultOverlayFile(arg);
            }
            else
            {
                usage();
            }
        }
       
        if (overlayer.getInputFile() == null || overlayer.getOutputFile() == null)
        {
            usage();
        }
       
        try
        {
            overlayer.overlay(specificPageOverlayFile,useNonSeqParser);
        }
        catch (Exception e)
        {
            LOG.error("Overlay failed: " + e.getMessage(), e);
            throw e;
View Full Code Here

     * @param args command line arguments
     * @throws Exception if something went wrong
     */
    public static void main(final String[] args) throws Exception
    {
        Overlay overlayer = new Overlay();
        Map<Integer, String> specificPageOverlayFile = new HashMap<Integer, String>();
        boolean useNonSeqParser = false;
        // input arguments
        for (int i = 0; i < args.length; i++)
        {
            String arg = args[i].trim();
            if (i == 0)
            {
                overlayer.setInputFile(arg);
            }
            else if (i == (args.length - 1))
            {
                overlayer.setOutputFile(arg);
            }
            else if (arg.equals(POSITION) && ((i + 1) < args.length))
            {
                if (Position.FOREGROUND.toString().equalsIgnoreCase(args[i + 1].trim()))
                {
                    overlayer.setOverlayPosition(Position.FOREGROUND);
                }
                else if (Position.BACKGROUND.toString().equalsIgnoreCase(args[i + 1].trim()))
                {
                    overlayer.setOverlayPosition(Position.BACKGROUND);
                }
                else
                {
                    usage();
                }
                i += 1;
            }
            else if (arg.equals(ODD) && ((i + 1) < args.length))
            {
                overlayer.setOddPageOverlayFile(args[i + 1].trim());
                i += 1;
            }
            else if (arg.equals(EVEN) && ((i + 1) < args.length))
            {
                overlayer.setEvenPageOverlayFile(args[i + 1].trim());
                i += 1;
            }
            else if (arg.equals(FIRST) && ((i + 1) < args.length))
            {
                overlayer.setFirstPageOverlayFile(args[i + 1].trim());
                i += 1;
            }
            else if (arg.equals(LAST) && ((i + 1) < args.length))
            {
                overlayer.setLastPageOverlayFile(args[i + 1].trim());
                i += 1;
            }
            else if (arg.equals(USEALLPAGES) && ((i + 1) < args.length))
            {
                overlayer.setAllPagesOverlayFile(args[i + 1].trim());
                i += 1;
            }
            else if (arg.equals(PAGE) && ((i + 2) < args.length) && (isInteger(args[i + 1].trim())))
            {
                specificPageOverlayFile.put(Integer.parseInt(args[i + 1].trim()), args[i + 2].trim());
                i += 2;
            }
            else if( args[i].equals( NONSEQ ) )
            {
                useNonSeqParser = true;
            }
            else if (overlayer.getDefaultOverlayFile() == null)
            {
                overlayer.setDefaultOverlayFile(arg);
            }
            else
            {
                usage();
            }
        }
       
        if (overlayer.getInputFile() == null || overlayer.getOutputFile() == null)
        {
            usage();
        }
       
        try
        {
            overlayer.overlay(specificPageOverlayFile,useNonSeqParser);
        }
        catch (Exception e)
        {
            LOG.error("Overlay failed: " + e.getMessage(), e);
            throw e;
View Full Code Here

TOP

Related Classes of org.apache.pdfbox.util.Overlay

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.