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

Free Support Forum - aspose.com

Odd problem with Replace - the character "U" is missing

Hi, I use the latest version 21.9.0 and I need to replace text phrases in a PDF document. To accomplish this task I have used sample code from aspose.com:

My code sample below searches for the phrase “FrauHerrn” and replaces this phrase with “This works as it should!”. Actually, this works as it should.

Subsequently my code sample searches for the phrase ““VornameNachname”” and is supposed to replace this phrase with “Uwe”. However, in the output-PDF “VornameNachname” is replaced with “we” and the “U” is missing.

If I change the code from “Uwe” to “Owe” the phrase “VornameNachname” is replaced with “Owe” - as it should.

The attached link allows the download of the VS Windows Forms sample project, the PDF-file required to replicate the issue and the corresponding word document.

Many thanks in advance for any help.

Stefan

        Document pdfDocument = new Document("c:\\BKAbrNachzahlung.pdf");
            

        TextFragmentAbsorber textFragmentAbsorber1 = new TextFragmentAbsorber("FrauHerrn");
        pdfDocument.Pages.Accept(textFragmentAbsorber1);
        TextFragmentCollection textFragmentCollection1 = textFragmentAbsorber1.TextFragments;
        foreach (TextFragment textFragment in textFragmentCollection1)
        {
            textFragment.Text = "This works as it should!";
            textFragment.TextState.Font = FontRepository.FindFont("Arial");
            textFragment.TextState.FontSize = 11;
            textFragment.TextState.FontStyle = FontStyles.Regular;
        }

        TextFragmentAbsorber textFragmentAbsorber2 = new TextFragmentAbsorber("VornameNachname");
        pdfDocument.Pages.Accept(textFragmentAbsorber2);
        TextFragmentCollection textFragmentCollection2 = textFragmentAbsorber2.TextFragments;
        foreach (TextFragment textFragment in textFragmentCollection2)
        {
            textFragment.Text = "Uwe";
            textFragment.TextState.Font = FontRepository.FindFont("Arial");
            textFragment.TextState.FontSize = 11;
            textFragment.TextState.FontStyle = FontStyles.Regular;
        }

        pdfDocument.Save("c:\\BKAbrNachzahlung_out.pdf");

@stefan.ossowski

We were able to reproduce the similar issue in our environment. Therefore, it has been logged as PDFNET-50640 in our issue tracking system. We will further look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.