import aspose.pdf as pdf # Initialize Document class object document = pdf.Document("input.pdf") rect = pdf.Rectangle(200, 200, 300, 250 , True) # Create RedactionAnnotation instance annot = pdf.annotations.RedactionAnnotation(document.pages[1] , rect) annot.fill_color = pdf.Color.green annot.border_color = pdf.Color.yellow annot.color = pdf.Color.blue annot.overlay_text = "REDACTED" # Add annotation document.pages[1].annotations.add(annot , True) # Flattens annotation and redacts page contents annot.redact() document.save("redacted.pdf")