Loads a RedactionPolicy instance from a stream containing XML configuration.
defload(cls,input):...
Parameter
Type
Description
input
io.RawIOBase
Stream containing XML configuration.
Returns: RedactionPolicy: The loaded redaction policy.
Example
frompathlibimportPathfromgroupdocs.redactionimportRedactor,RedactionPolicy,RedactionStatusfromgroupdocs.redaction.optionsimportSaveOptions# Load the policy from an XML filewithopen("RedactionPolicy.xml","rb")asstream:policy=RedactionPolicy.load(stream)inbound=Path("inbound")done,failed=Path("outbound/done"),Path("outbound/failed")done.mkdir(parents=True,exist_ok=True)failed.mkdir(parents=True,exist_ok=True)forfile_pathininbound.iterdir():iffile_path.is_file():withRedactor(str(file_path))asredactor:result=redactor.apply(policy)target_folder=doneifresult.status!=RedactionStatus.FAILEDelsefailedwithopen(str(target_folder/file_path.name),"wb")asout_stream:redactor.save(out_stream,SaveOptions(rasterize_to_pdf=False))# keep the format
Aliases
These names call load too, limited to the overloads listed.