Saving document as a rasterized PDF, you can specify starting page index (zero based) and the number of pages from this index to save. Also, you can change the Compliance level from PDF/A-1b, which is used by default, to PDF/A-1a:
fromgroupdocs.redactionimportRedactor,RedactionStatusfromgroupdocs.redaction.optionsimportSaveOptions,PdfComplianceLevelfromgroupdocs.redaction.redactionsimportExactPhraseRedaction,ReplacementOptionsfromgroupdocs.pydrawingimportColordefselect_specific_pages_for_rasterized_pdf():# Define the color of redactioncolor=Color.from_argb(255,220,20,60)# Specify the redaction optionsrepl_opt=ReplacementOptions(color)ex_red=ExactPhraseRedaction("John Doe",repl_opt)# Load the document to be redactedwithRedactor("./multipage_sample.docx")asredactor:# Apply the redactionresult=redactor.apply(ex_red)ifresult.status!=RedactionStatus.FAILED:# Save the processed document, selecting the page range and compliance levelso=SaveOptions()so.rasterization.enabled=True# convert pages to images for compatibilityso.rasterization.page_index=5# start from 6th page (index is 0-based)so.rasterization.page_count=1# save only one pageso.rasterization.compliance=PdfComplianceLevel.PDF_A1A# PDF/A-1a formatso.add_suffix=Falseresult_path=redactor.save(so)print(f"Document redacted successfully.\nCheck output in {result_path}")else:print("Redaction failed!")if__name__=="__main__":select_specific_pages_for_rasterized_pdf()
multipage_sample.docx is the sample file used in this example. Click here to download it.