You can combine PageRangeFilter and PageAreaFilter filters in one set in order to set the scope of redaction to an area on a specific page. You have to set an array of instances to Filters property of the ReplacementOptions.
The following example demonstrates how to apply redaction to the bottom half of the last page in a PDF document.
fromgroupdocs.redactionimportRedactorfromgroupdocs.redaction.optionsimportSaveOptionsfromgroupdocs.redaction.redactionsimport(ExactPhraseRedaction,ReplacementOptions,PageRangeFilter,PageAreaFilter,PageSeekOrigin,)fromgroupdocs.pydrawingimportPoint,Sizedefuse_pdf_redaction_filters():# Load the document to be redactedwithRedactor("./multipage_sample.pdf")asredactor:# Get the actual size information for the last pagedoc_info=redactor.get_document_info()last_page=doc_info.pages[doc_info.page_count-1]# Define the redaction area start pointsample_point=Point(0,int(last_page.height/2))# Define the redaction area sizesample_size=Size(last_page.width,int(last_page.height/2))# Combine page-range and page-area filters to scope the redactionfilters=[PageRangeFilter(PageSeekOrigin.END,0,1),PageAreaFilter(sample_point,sample_size),]# Specify the redaction options with the filtersrepl_opt=ReplacementOptions("[secret]")repl_opt.filters=filtersex_red=ExactPhraseRedaction("bibliography",False,repl_opt)# Apply the redactionredactor.apply(ex_red)# Save the redacted documentsave_options=SaveOptions()save_options.add_suffix=Truesave_options.rasterize_to_pdf=Truesave_options.redacted_file_suffix="redacted"result_path=redactor.save(save_options)print(f"Document redacted successfully.\nCheck output in {result_path}.")if__name__=="__main__":use_pdf_redaction_filters()
multipage_sample.pdf is the sample file used in this example. Click here to download it.