Aspose.PDF .NET Technical Drawing Text Replacement

Hello,

I have a technical drawing PDF in which I want to replace some text strings.
After replacement, I am able to highlight the textFragments. Visible is still the old text, but when I copy/paste the highlighted text to Notepad, the replacement text is actually embedded.

Any ideas why the visual text is not updated? The PDF is not protected.

Thank you and kind regards,

Dan

@DaanTheoden
It’s best if you provide the original document and the code used (or at least the resulting document).
In order not to build a lot of assumptions, but to understand.
Offhand, these can be different layers or encoding features.

Hello Sergei,

Thank you for getting back. Please find the input PDF, output PDF and code attached.

        Aspose.Pdf.License license = new Aspose.Pdf.License();

        try

        {

            // Set license

            license.SetLicense("./Aspose.PDFfor.NET.lic");

        }

        catch (Exception)

        {

            // something went wrong

            throw;

        }

        // Open document

        Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document("./test_in.pdf");

        // Create TextAbsorber object to find all instances of the input search phrase

        Aspose.Pdf.Text.TextFragmentAbsorber textFragmentAbsorber = new Aspose.Pdf.Text.TextFragmentAbsorber("OPERATION");

        // Accept the absorber for all the pages

        pdfDocument.Pages.Accept(textFragmentAbsorber);

        // Get the extracted text fragments

        Aspose.Pdf.Text.TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;

        // Loop through the fragments

        foreach (Aspose.Pdf.Text.TextFragment textFragment in textFragmentCollection)

        {

            // Update text and other properties

            textFragment.Text = "Hello World";

            textFragment.ZIndex = 999;

            textFragment.TextState.Font = Aspose.Pdf.Text.FontRepository.FindFont("Arial");

            textFragment.TextState.FontSize = 22;

            textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Black);

        }

       

        // Save resulting PDF document.

        pdfDocument.Save("./test_out.pdf");

test_in.pdf (52.2 KB)
test_out.pdf (125.1 KB)

Kind regards,

Daan

@DaanTheoden
In the attached document, the text OPERATION is made in addition to the text, also in vector graphics. I thought that if remove it, the changed text will become visible, but I have not succeeded so far. It seems that something else is covering the text (white rectangle?). I will continue to study the document and will write to you when I have more information (or I set a task for the development team).

@DaanTheoden
We have opened the following new ticket in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-55472

You can obtain paid_support if you need support on a priority basis, along with the direct access to our Paid Support management team.