Issue with Adding Borders to RedactionAnnotation in Aspose.PDF

Hello Aspose Team,

We are trying to apply a black border around redactions placed on PDF files using the RedactionAnnotation class from Aspose.Pdf.Annotations, but we cannot get it to work.

Here is the code that we are using(adapted from the sample provided in your doc):

RedactionAnnotation annot = new RedactionAnnotation(this.page, markupBox.Rectangle);
annot.FillColor = Aspose.Pdf.Color.White;
annot.BorderColor = Aspose.Pdf.Color.Black;
annot.Color = Aspose.Pdf.Color.Black;

Aspose.Pdf.Annotations.Border border = new Aspose.Pdf.Annotations.Border(annot);
border.Width = 1;
border.Style = BorderStyle.Solid;
annot.Border = border;

this.page.Annotations.Add(annot);

annot.Redact();

When we execute this code, the redaction appears as a white block without any visible border. Please see the attached screenshot for reference:
{EB089F08-5EE7-4593-8118-E4D55FF7F958}.jpg (40.5 KB)

Questions:

  1. Is this known issue to Aspose.PDF?
  2. Is there any way to workaround to this?
  3. We also tried placing redaction using RedactArea API from Aspse.Pdf.Facades but it doesn’t give option for border color. Are there any alternative?

@jungsun.park
What version of the library are you using?

@sergei.shibanov
We are currently using 23.7.0. But, I also tried with the latest 24.11.0 and saw same issue.

@jungsun.park
Please attach the document you are working with that this is happening.

It honestly works with any PDF document but here I attached PDF that I addded some redaction annotations to.

REDACTED_REL0000000005 (5).pdf (1.2 MB)

@jungsun.park
Border with the settings set for it is displayed before RedactionAnnotation.Redact() is called.
You can see this by commenting out the line

annot.Redact();

@sergei.shibanov

I see that border is displayed before annot.Redact(); is called but this won’t really work as redaction because these redaction annotations are removable without calling Redact() and can reveal sensitive data that needs to be actually redacted.

@jungsun.park
This two-step process is defined by the pdf specification and the logic behind this approach is specified there.
Accordingly, border is used to visually highlight the intended location of the parts to be removed in the first step.

red.png (63.7 KB)

12.5.6.23 Redaction annotations
A redaction annotation (PDF 1.7) identifies content that is intended to be removed from the document. The intent of redaction annotations is to enable the following process:
a) Content identification. A user applies redact annotations that specify the pieces or regions of content that should be removed. Up until the next step is performed, the user can see, move and redefine these annotations.
b) Content removal. The user instructs the viewer application to apply the redact annotations, after which the content in the area specified by the redact annotations is removed. In the removed content’s place, some marking appears to indicate the area has been redacted. Also, the redact annotations are removed from the PDF document.
Redaction annotations provide a mechanism for the first step in the redaction process (content identification). This allows content to be marked for redaction in a non-destructive way, thus enabling a review process for evaluating potential redactions prior to removing the specified content.
Redaction annotations shall provide enough information to be used in the second phase of the redaction process (content removal). This phase is application-specific and requires the PDF processor to remove all content identified by the redaction annotation, as well as the annotation itself. Interactive PDF processors that support redaction annotations shall provide a mechanism for applying content removal, and they shall remove all traces of the specified content. If a portion of an image is contained in a redaction region, that portion of the image data shall be destroyed; clipping or image masks shall not be used to hide that data. Such interactive PDF processors shall also be diligent in their consideration of all content that can exist in a PDF document. “Table 195 — Additional entries specific to a redaction annotation” shows the additional entries specific to redaction annotations.

While I understand that the redaction annotation is primarily intended to visually highlight the areas to be reviewed and redacted in the first step, the issue arises during the second step, where the actual redaction is applied. As per the specification, after redaction, the underlying content is removed, leaving a marking to indicate the redacted area. However, in many cases (most PDFs have white background), this marking is simply a white space without any distinguishing border or color.

It’s also strange that when annot.Redact() is called fill color is persisted to the redacted area but not the border color. This does not make sense to me.

@jungsun.park

You can use the OverlayText property.
The text specified in it will be displayed both after the first step (adding the annotation) and after its applying, after removing the context.
If necessary, you can manually add a frame (say, like SquareAnnotation), although this is inconvenient.

@jungsun.park

And besides, it is better to specify a fill color other than white if you want the edited area to stand out.