public static void tag(String catalogFile, String tagFile) {
        ObjectOutputStream tagOutput = null;
        try {
            FileOutputStream fos = new FileOutputStream(tagFile);
            BufferedOutputStream bos = new BufferedOutputStream(fos, 4096*4);
            tagOutput = new ObjectOutputStream(bos);
        }
        catch(IOException e) {
            System.out.println("Problem openning tagFile: " + e);
        }

        ArrayList allFiles = null;
        try {
            FileInputStream fis = new FileInputStream(catalogFile);
            BufferedInputStream bis = new BufferedInputStream(fis, 4096*4);
            ObjectInputStream ois = new ObjectInputStream(bis);
            allFiles = (ArrayList) ois.readObject();
            ois.close();
        }
        catch(IOException e) {
            System.out.println("Problem openning catalogFile: " + e);
            return;
        }
        catch(ClassNotFoundException e) {
            System.out.println("Problem reading catalog from ["+catalogFile+"]: " + e);
            return;
        }

        System.out.println("Found " + allFiles.size() + " PDF files to tag");
        long then = 0;
        for(int i = 0; i < allFiles.size(); i++) {
            File file = (File) allFiles.get(i);
            String path = file.getAbsolutePath();
            long now = System.currentTimeMillis();
            if ((now - then) >= 5000L) {
                then = now;
                System.out.println("Commencing tagging file " + (i+1) + " of " + allFiles.size());
                System.out.println(path);
            }
            //long before = System.currentTimeMillis();
            tagPdf(path);
            //long after = System.currentTimeMillis();
            //System.out.println("Duration: " + (after-before));
            System.out.println("Used memory: " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()));
        }
        System.out.println("Finished tagging " + allFiles.size() + " PDF files");
        //if (true) return;

        try {
            TagState state = Tagger.getTagState();
            tagOutput.writeObject(state);
            tagOutput.flush();
            tagOutput.close();
        }
        catch(IOException e) {
            System.out.println("Problem saving tags: " + e);
        }
    }