Free Support Forum - aspose.com

Aspose.PDF for .NET Replaced text still searchable

The problem is that after replacement of the text in this document I opened the edited document in Acrobat Reader DC and text that was replaced still searchable.
Before this document, I tried other document and everything seems fine, I was not able to find the replaced text.
Document: https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf
Code:
`var inputFilePath = @“D:\PDF32000_2008.pdf”;
var outputFilePath = @“D:\PDF32000_2008EDITED.pdf”;

            var pdfDocument = new Document(inputFilePath);
            var textFragmentAbsorber =
                new TextFragmentAbsorber("rights");
            pdfDocument.Pages.Accept(textFragmentAbsorber);

            var textFragmentCollection = textFragmentAbsorber.TextFragments;
            foreach (var textFragment in textFragmentCollection)
            {
                textFragment.Text = CreateBlocks(textFragment.Text.Length);
            }
            
            pdfDocument.Save(outputFilePath);`

I don’t need replaced text to be searchable. Any solution regarding this?

@nikitamarchenko

Thank you for contacting support.

We have worked with the data shared by you and have been able to reproduce the issue with below code snippet because definition of CreateBlocks method is not present. A ticket with ID PDFNET-45352 has been logged in our issue management system for further investigation and resolution. The ticket ID has been linked with this thread so that you will receive notification as soon as the ticket is resolved.

        var inputFilePath = dataDir + @"PDF32000_2008.pdf";
        var outputFilePath = dataDir + @"PDF32000_2008EDITED.pdf";

        var pdfDocument = new Document(inputFilePath);
        var textFragmentAbsorber =
            new TextFragmentAbsorber("rights");
        pdfDocument.Pages.Accept(textFragmentAbsorber);

        var textFragmentCollection = textFragmentAbsorber.TextFragments;
        foreach (var textFragment in textFragmentCollection)
        {
            textFragment.Text = "REPLACED";
        }            
        pdfDocument.Save(outputFilePath);

We are sorry for the inconvenience.

@Farhan.Raza

CreateBlocks creates a string of ‘█’ characters with the same length as the one that needs to be replaced but it’s not so important.

Thank you for your support.

@nikitamarchenko

Thank you for elaborating. We will get back to you once we have any significant update available regarding this ticket.