We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Redact annotation orientation issue

I have redacted the “document” word from the “sample.pdf”. The searchable text was removed correctly but the black redaction rectangles are in the wrong positions. It seems like it has been rotated with 90°. What could cause this?

Aspose.PDF .NET 20.3 version

Original file: sample.pdf (1.9 MB)

After redaction: ScreenshotFromOneOfThePage.png (208.0 KB)

Code snippet:

	public void Redact()
	{
		foreach (Page actualPage in pdfDocument.Pages)
		{
			TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("document");
			textFragmentAbsorber.TextSearchOptions.IsRegularExpressionUsed = true;
			actualPage.Accept(textFragmentAbsorber);

			TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;

			foreach (TextFragment textFragment in textFragmentCollection)
			{
				Rectangle rect = textFragment.Rectangle;
				RedactionAnnotation annot = new RedactionAnnotation(actualPage, new Rectangle(rect.LLX + 1.0, rect.LLY, rect.URX - 1.0, rect.URY))
				{
					FillColor = Aspose.Pdf.Color.Black,
				};

				actualPage.Annotations.Add(annot);
				annot.Redact();
			}
		}
		pdfDocument.Save("output.pdf");
	}

Thanks,

Gabor

@erdeiga,

Thanks for sharing further details.

We have logged an investigation ticket as PDFNET-47866 in our issue tracking system. We will further look into details of it and keep you posted with the status of its resolution. Please be patient and spare us some time.

We are sorry for the inconvenience.