PDFTron JAVA SDK CANNOT DELETE FILE

Hello,
I’m using this PDFTron example to extract the logical structure of tagged PDFs. After extracting the structure I 'am not able to delete the file from JAVA I’m getting the following error in JAVA on Windows 10.

The process cannot access the file because it is being used by another process

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Hello,

To get a better understanding of the issue you are running into, are you able to provide us with some sample code/project for us to test on our end?

Thank you in advance for the additional information.

PDFNet.initialize("KEY OVER HERE");
		try { // Extract Logical Structure from PDF document and return it.
			pdfTronDoc = new PDFDoc(inputFile);
			pdfTronDoc.lockRead();
			pdfTronDoc.initSecurityHandler();
			STree tree = pdfTronDoc.getStructTree();
			if (tree.isValid()) {
				System.out.println("Document has a StructTree root.");
			} else {
				System.out.println("This document does not contain any logical structure.");
			}
			System.out.println("Extraction of PDF logical structure and page content.");
			{
				// A map which maps page numbers(as Integers)
				// to page Maps(which map from struct mcid(as Integers) to text Strings)
				Map<Integer, Map<Integer, String>> mcid_doc_map = new TreeMap<Integer, Map<Integer, String>>();
				ElementReader reader = new ElementReader();
				for (PageIterator itr = pdfTronDoc.getPageIterator(); itr.hasNext();) {
					Page current = itr.next();
					reader.begin(current);
					Map<Integer, String> page_mcid_map = new TreeMap<Integer, String>();
					mcid_doc_map.put(Integer.valueOf(current.getIndex()), page_mcid_map);
					ProcessElements2(reader, page_mcid_map);
					reader.end();
				}
				if (tree.isValid()) {
					for (int i = 0; i < tree.getNumKids(); ++i) {
						ProcessStructElement2(tree.getKid(i), mcid_doc_map, 0);
					}
				}
			}
			
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		try {
			pdfTronDoc.unlockRead();
			pdfTronDoc.close();
			System.out.println("Closed Document");
		} catch (PDFNetException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return new HashMap<String, ArrayList<String>>(documentMap);
	}

The above code is to extract the content using pdftron.
and below is the code to delete the file.

Files.delete(deletePDF);

Basically after opening the file with PDFTron and reading the contents I cannot delete the file. I get the following error “The process cannot access the file because it is being used by another process” using the JAVA SDK on Windows 10.

Hello,

Thank you for your response. I see you are using the Files API to load the document. In order for us to reproduce the exact issue on our end, could you please provide us with the full code along with an example file you are using ? In addition, are you experiencing this issue with all files, or just some?