We have written a custom workflow step. It has the following code. The idea is to set a Document variable to the value of a file from the filesystem.
Path filePath = Paths.get(path);
com.adobe.aemfd.docmanager.Document doc = new com.adobe.aemfd.docmanager.Document(Files.readAllBytes(filePath));
This succeeds however, we we attempt to use the Document variable, we get the error "Document is in a disposed state!".
How do I properly set a Document variable with the contents of a file on the filesystem?
Solved! Go to Solution.
Can you try the following code. This has been used in this sample code as well.
import java.io.File; import com.adobe.aemfd.docmanager.Document; String inputFile = "<path to a pdf document stored at disk>" File inFile = new File(inputFile); Document inDoc = new Document(inFile);
This should work. not sure why it is not working for you.
As an alternative can you try with this:
byte bytes = <create byte from file> Document inDoc = new Document(bytes);