Saves the document to a file using the provided SaveOptions. By default, AddSuffix is set to True and RasterizeToPDF is set to True.
defsave(self):...
Returns: str: Path to the redacted document.
save
Saves the document to a file.
defsave(self,save_options):...
Parameter
Type
Description
save_options
SaveOptions
Options to add suffix or rasterize.
Returns: str: Path to redacted document.
Example
fromdatetimeimportdatetimefromgroupdocs.redactionimportRedactorfromgroupdocs.redaction.optionsimportSaveOptionsfromgroupdocs.redaction.redactionsimportExactPhraseRedaction,ReplacementOptionsdefsave_in_original_format():repl_opt=ReplacementOptions("[personal]")ex_red=ExactPhraseRedaction("Emily Johnson",repl_opt)withRedactor("./sample.docx")asredactor:redactor.apply(ex_red)so=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}.")
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
importosfromgroupdocs.redactionimportRedactorfromgroupdocs.redaction.optionsimportRasterizationOptions,PdfComplianceLevelwithRedactor("SomePresentation.pptx")asredactor:# Set rasterization options (e.g., first slide only)rasterization_options=RasterizationOptions()rasterization_options.page_index=0rasterization_options.page_count=1rasterization_options.compliance=PdfComplianceLevel.PDF_A1A# Save the redacted document to a file streamoutput_path=os.path.join(r"C:\Temp","PresentationFirstSlide.pdf")withopen(output_path,"w+b")asstream:# read/write: PDF/A conversion reads it backredactor.save(stream,rasterization_options)
save
Saves the document to the specified stream.
defsave(self,document,save_options):...
Parameter
Type
Description
document
io.RawIOBase
The target stream.
save_options
SaveOptions
The save options that control rasterization, the output file name suffix, and document-specific save settings.
Example
importiofromgroupdocs.redactionimportRedactorfromgroupdocs.redaction.optionsimportSaveOptionswithRedactor("document.docx")asredactor:# Apply redactions as neededbuf=io.BytesIO()redactor.save(buf,SaveOptions(rasterize_to_pdf=False))data=buf.getvalue()
Aliases
These names call save too, limited to the overloads listed.