As an alternative to a local file, Redactor can open a document from stream.
The following example demonstrates how to load and redact a document using Stream:
finalFileInputStreamstream=newFileInputStream("sample.docx");try{finalRedactorredactor=newRedactor(stream);try{// Here we can use document instance to make redactions
redactor.apply(newDeleteAnnotationRedaction());finalFileOutputStreamoutputStream=newFileOutputStream("redacted-sample.pdf");try{RasterizationOptionsoptions=newRasterizationOptions();options.setEnabled(true);redactor.save(outputStream,options);}finally{outputStream.close();}}finally{redactor.close();}}finally{stream.close();}
sample.docx is the sample file used in this example. Click here to download it.