How to stop generating .vbs file when .doc is converted to ..pdf using document4j

410 Views Asked by At

I have written this code and when I run the program it runs successfully, but it also print .vbs file along with this and I don't want that file as it will load my file system.

 File fs=new File("D:/parser/samrudha-kelkar.docx");  
        File file=new File("D:/test.pdf");

        IConverter converter = LocalConverter.builder().build();

         Future<Boolean> conversion = converter
                 .convert(fs).as(DocumentType.MS_WORD)
                 .to(file).as(DocumentType.PDF)
                 .prioritizeWith(1000) // optional
                 .schedule();
2

There are 2 best solutions below

0
On

Just call converter.shutdown(), documents4j should clean up after itself and leave you with an empty folder which you can safely delete. Note that any running job needs to terminate before the folder will be cleaned up.

0
On

You can do this:

IConverter converter = LocalConverter.builder()
                    .baseFolder(new File("D:/parser/tmp"))
                    .workerPool(20, 25, 2, TimeUnit.SECONDS)
                    .processTimeout(5, TimeUnit.SECONDS)
                    .build();

FileUtils.deleteDirectory("D:/parser/tmp");

I think that you have to create .vbs files in order to do the conversion