private static void tagPdf(String path) {
        Document pdfDoc = new Document();
        try {
            pdfDoc.setFile(path);
        } catch (Exception e) {
            e.printStackTrace();
        }

        if(Tagger.tagging)
            Tagger.setCurrentDocument(pdfDoc);

        int numberOfPages = pdfDoc.getNumberOfPages();
        for (int pageNumber = 0; pageNumber < numberOfPages; pageNumber++) {
            if(Tagger.tagging)
                Tagger.setCurrentPageIndex(pageNumber);

            Page page = pdfDoc.getPageTree().getPage(pageNumber, TagUtil.class);
            if (page != null) {
                page.init();
                pdfDoc.getPageTree().releasePage(page, TagUtil.class);
                // So the system remains responsive
                try { Thread.sleep(20L); } catch(InterruptedException e) {}
            }
        }
        pdfDoc.dispose();
    }