Spacing changes after changing case

Often but less often than not, when changing the case of letter, the spacing spacing after the new now lower case letter is shrunk and the right letter almost touches the previous letter.

Does the entire text fragment need to be replaced with a new textfragment to recalculate the appropriate spacing? If so I don’t see a TextFragment.Remove function or anything in the Page document.

@mjanulaitis

Thank you for contacting support.

Please note that the text fragments with keywords contain some other text and for replacing only the keywords without related text, we should set TextReplaceOptions.ReplaceAdjustment.None as under:

TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("XYZ");
TextReplaceOptions objTextReplaceOptions = new TextReplaceOptions(TextReplaceOptions.ReplaceAdjustment.None)
{
    ReplaceAdjustmentAction = TextReplaceOptions.ReplaceAdjustment.None
};
textFragmentAbsorber.TextReplaceOptions = objTextReplaceOptions;

If you still face the problem while using Aspose.PDF for .NET 19.3 then please share narrowed down code snippet along with source and generated files so that we may investigate further to help you out.

I made the chance and noticed some difference in my modified docs however I still see my lower case t smashed up against the next letter.

Here’s the basics:

TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber();
TextReplaceOptions objTextReplaceOptions = new TextReplaceOptions(TextReplaceOptions.ReplaceAdjustment.None)
{
ReplaceAdjustmentAction = TextReplaceOptions.ReplaceAdjustment.None
};
textFragmentAbsorber.TextReplaceOptions = objTextReplaceOptions;

        document.Pages.Accept(textFragmentAbsorber);
        TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;

        foreach (TextFragment textFragment in textFragmentCollection)
        {
            textFragment,Text.Replace("Trade", "trade");
        }

@mjanulaitis

Would you please share source and generated files so that we may try to reproduce and investigate it further.

Here are the files. Notice the lower case ‘t’ is kissing the next letter. Also the annotations are using the rectangles for each character in the modified TextFragment. It seems the rectangle is off. Sometimes it overlaps the next character.

Before
1008163ETU2018TaxFairBoothNameBoards120x40_71478527.pdf (523.9 KB)

After
1008163ETU2018TaxFairBoothNameBoards120x40_71478527.pdf (553.0 KB)

@mjanulaitis

We have noticed the difference in your PDF documents but shared data is not reproducing the issue in our environment. The code snippet generates identical PDF document so kindly review the code and ensure sharing SSCCE code so that we may proceed to assist you accordingly. We appreciate your cooperation in this regard.

Farhan, please try with the code below using this file:

1008163ETU2018TaxFairBoothNameBoards120x40_71478527.pdf (523.9 KB)

You will notice the lower case t is now kissing the r.

    static void Main(string[] args)
    {
        var license = new License();
        license.SetLicense(LICENSE_KEY);

        var document = new Document(FILENAME);
        var textFragmentAbsorber = new TextFragmentAbsorber();
        var objTextReplaceOptions = new TextReplaceOptions(TextReplaceOptions.ReplaceAdjustment.None);
        textFragmentAbsorber.TextReplaceOptions = objTextReplaceOptions;
        document.Pages.Accept(textFragmentAbsorber);

        foreach (TextFragment tf in textFragmentAbsorber.TextFragments)
        {
            if (tf.Text.Contains("Transformations"))
                tf.Text = tf.Text.Replace("Transformations", "transformations");
        }
        
        document.Save($"{FILENAME.Replace(".pdf", "_updated.pdf")}");
    }

@mjanulaitis

We have been able to reproduce the issue in our environment. A ticket with ID PDFNET-46220 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.

We are sorry for the inconvenience.