"Depending on the length of the text, the following characters appear unevenly. Is there a way to fix this?"

“Depending on the length of the text, the following characters appear unevenly. Is there a way to fix this?”
MACROGEN_EngHealthCare.pdf (3.5 MB)

                            // Create TextAbsorber object to find all instances of the input search phrase
                            textFragmentAbsorber = new TextFragmentAbsorber("SerialNumber2");

                            // Accept the absorber for all the pages
                            pdfDocument.Pages.Accept(textFragmentAbsorber);

                            // Get the extracted text fragments
                            TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
                            if (textFragmentCollection.Count > 0)
                            {
                                // Get first occurance of text and replace
                                TextFragment textFragment = textFragmentCollection[1];
                                // Update text and other properties
                                textFragment.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Left;
                                textFragment.Text = SerialNumber;
                                textFragment.TextState.Font.IsEmbedded = true;
                                textFragment.TextState.Font = FontRepository.FindFont("10X10", FontStyles.Regular);
                                textFragment.TextState.FontSize = 9;

                                Console.WriteLine("\nText replaced successfully.\nFile saved at " + dataDir);
                            }

                            // Create TextAbsorber object to find all instances of the input search phrase
                            textFragmentAbsorber = new TextFragmentAbsorber("InstitutuionName2");

                            // Accept the absorber for all the pages
                            pdfDocument.Pages.Accept(textFragmentAbsorber);

                            // Get the extracted text fragments
                            textFragmentCollection = textFragmentAbsorber.TextFragments;
                            if (textFragmentCollection.Count > 0)
                            {
                                // Get first occurance of text and replace
                                TextFragment textFragment = textFragmentCollection[1];
                                // Update text and other properties
                                textFragment.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Left;
                                textFragment.Text = InstitutuionName;
                                textFragment.TextState.Font.IsEmbedded = true;
                                textFragment.TextState.Font = FontRepository.FindFont("10X10", FontStyles.Regular);
                                textFragment.TextState.FontSize = 9;

                                Console.WriteLine("\nText replaced successfully.\nFile saved at " + dataDir);
                            }

page_ MACROGEN_EngHealthCare.pdf (3.6 MB)

@hbhur102

Are you using 25.6 version of the API and are you performing any other operation on the PDF as well after saving through the API? We have checked the output file and it looks like it was saved finally by some other application.

“I am using version 24.3. This was a test case where we developed a program to dynamically process fields like ‘serialnumber2’ on the cover page using genetic test data provided by the client.”

MACROGEN_EngHealthCare.pdf (3.6 MB)

“This was created using the API only, without any other operations. The files starting with ‘page_’ were processed using the API, and then a single page was extracted from multiple pages using Acrobat Pro.”

@hbhur102

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

Issue ID(s): PDFNET-60129

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