Free Support Forum - aspose.com

Using TextFragmentAbsorber for search and replace

Hello, I am using the following code to perform search and replace. Although the resulting PDF indicates that some replacement is happening, the new text is being truncated by some sort of invisible box. The reason I know this is becuase I can see the edge of the next character in my string. Any help would be greatly appreaciated.

Document pdfDocument = new Document(pdfTemplateName.ToString());

TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("FirstXXXXXXMiddleXXXXXXLast");

PdfDocument.Pages[1].Accept(textFragmentAbsorber);

TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;

foreach (TextFragment textFragment in textFragmentCollection)

{

//update text and other properties

textFragment.Text = FirstMiddleLastName.ToString();

//textFragment.TextState.Font = FontRepository.FindFont("Verdana");

//textFragment.TextState.FontSize = 22;

//textFragment.TextState.ForegroundColor =

//System.Drawing.Color.Blue;

//textFragment.TextState.BackgroundColor =

//System.Drawing.Color.Green;

}

Sorry about the formatting, don't know what happened during the paste.

Hi Kerry,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Please share your template PDF file to show the issue. This will help us reproduce the issue soon.

Thank You & Best Regards,