The following example demonstrates how to save the document as a rasterized PDF file:
fromgroupdocs.redactionimportRedactorfromgroupdocs.redaction.optionsimportSaveOptionsfromgroupdocs.redaction.redactionsimportExactPhraseRedaction,ReplacementOptionsdefsave_in_rasterized_pdf():# 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 as a rasterized PDFso=SaveOptions()so.add_suffix=Falseso.rasterize_to_pdf=Trueresult_path=redactor.save(so)print(f"Document redacted successfully.\nCheck output in {result_path}.")if__name__=="__main__":save_in_rasterized_pdf()
sample.docx is the sample file used in this example. Click here to download it.