import groupdocs.redaction as gr
import groupdocs.redaction.options as gro
import groupdocs.redaction.redactions as grr
import groupdocs.pydrawing as grd
# Define overlay size, position, and color
replacement_size = grd.Size(300, 30)
color = grd.Color.from_argb(255, 220, 20, 60)
replacement_options = grr.RegionReplacementOptions(color, replacement_size)
replacement_point = grd.Point(20, 125)
redaction = grr.ImageAreaRedaction(replacement_point, replacement_options)
# Select the specific image section
redaction.filters = [
grr.PageRangeFilter(grr.PageSeekOrigin.BEGIN, 0, 1),
grr.PageAreaFilter(grd.Point(0, 300), grd.Size(600, 600))
]
# Open the file for redaction
with gr.Redactor("source.xslx") as redactor:
# Apply overlay to hide the area
result = redactor.apply(redaction)
# Save the modified document
save_options = gro.SaveOptions()
save_options.add_suffix = True
save_options.rasterize_to_pdf = False
result_path = redactor.save(save_options)