Free Support Forum -

Replace TextFragment does not re - arrange Table content

Hi all,
In .Net, after using TextFragmentAbsorber to replace text in a PDF file, the page Content was not adjusted.
Please look at attached pdf: beforeReplace.pdf (126.0 KB)

All my Texts are within a table and what I want to do is to replace this text with another text, that I’m getting from another Source (SharePoint Rest Statment to get metadata from a SharePoint List Item).
So: “<%Field.Title%>” should be replaced to for example: “This is my Title”.
Well, that’s not really the Problem as you can see (Please look at attached file afterReplace.pdf (207.1 KB)
) that my Code is working fine (Except for some replacements, as I don’t implemented this step yet)
But there are Texts, which are longer than the original Text and my question is:
Is there a way to re-arrange the Content within a table?

Below my Code for replacement:

Document pdfDocument = new Document(@“C:\temp\beforeReplace.pdf”);
// Create TextFragmentAbsorber object to find all text occurrences between “<%” and “%>”
TextFragmentAbsorber absorber = new TextFragmentAbsorber(@"<%.*%>", new TextSearchOptions(true));
// Accept the absorber for all pages
TextFragmentCollection textFragmentCollection = absorber.TextFragments;
foreach(TextFragment fragment in textFragmentCollection)
if(!fragment.Text.Contains(“Field.”)) continue;
string internalName = fragment.Text.Split(new string[] {“Field.”}, StringSplitOptions.RemoveEmptyEntries)[1];
internalName = internalName.Substring(0, internalName.LastIndexOf("%"));
fragment.TextState.Font = FontRepository.FindFont(“Arial”);
fragment.TextState.FontSize = 8;
fragment.TextState.ForegroundColor = Color.Navy;
if(item[internalName] != null)
fragment.Text = item[internalName].Value?.ToString() ?? “”;



Thank you for contacting support.

We are afraid that rearrange or resize of table is not supported at the moment. However, we have logged a feature request with ID PDFNET-45089 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.