Saves the document to a file with the following options: AddSuffix = True, RasterizeToPDF = True.
defsave(self):...
Returns: str: Path to redacted document.
Example
fromgroupdocs.redactionimportRedactorfromgroupdocs.redaction.optionsimportSaveOptionsfromgroupdocs.redaction.redactionsimportExactPhraseRedaction,ReplacementOptionswithRedactor("document.docx")asredactor:redactor.apply(ExactPhraseRedaction("secret",ReplacementOptions("[X]")))options=SaveOptions()options.add_suffix=Trueoptions.rasterize_to_pdf=Trueresult_path=redactor.save(options)print(f"Saved to {result_path}")
save
Saves the document to a file.
defsave(self,save_options):...
Parameter
Type
Description
save_options
SaveOptions
Options to add suffix or rasterize.
Returns: Path to redacted document.
Example
fromdatetimeimportdatetimefromgroupdocs.redactionimportRedactorfromgroupdocs.redaction.optionsimportSaveOptionsfromgroupdocs.redaction.redactionsimportExactPhraseRedaction,ReplacementOptionsdefsave_in_original_format():# Specify the redaction optionsrepl_opt=ReplacementOptions("[personal]")ex_red=ExactPhraseRedaction("John Doe",repl_opt)# Load the document to be redactedwithRedactor("./sample.docx")asredactor:# Apply the redactionredactor.apply(ex_red)# Save the redacted document in its original format with a date suffixso=SaveOptions()so.add_suffix=Trueso.rasterize_to_pdf=Falseso.redacted_file_suffix=datetime.now().strftime("%Y-%m-%d %H-%M-%S")result_path=redactor.save(so)print(f"Document redacted successfully.\nCheck output in {result_path}.")if__name__=="__main__":save_in_original_format()
save
Saves the document to a stream, including custom location.
defsave(self,document,rasterization_options):...
Parameter
Type
Description
document
io.RawIOBase
Target stream.
rasterization_options
RasterizationOptions
Options to rasterize or not and to specify pages for rasterization.
Example
importiofromgroupdocs.redaction.optionsimportRasterizationOptionsfromgroupdocs.redactionimportRedactorwithRedactor("document.pptx")asredactor:# configure rasterization to process only the first slidero=RasterizationOptions()ro.page_index=0ro.page_count=1stream=io.BytesIO()redactor.save(stream,ro)# the BytesIO object now contains the saved documentdata=stream.getvalue()