2 screenshots are attached, one is before replace and other after replace.
There are 2 issues highlighted in screenshots,
Length of the hyperlink line (i.e blue line) after replacing text is same as before, it is not updating. (In the screen shot i have replaced “ICC” with “ICC replaced”)
If there are multiple hyperlinks in a line, all the hyperlinks formats are gone even if the one hyperlink text is replaced.
Below is the code that i’m using to replace Text,
PdfContentEditor pdfContentEditor = new PdfContentEditor();
pdfContentEditor.BindPdf(Pdfdocument);
pdfContentEditor.TextReplaceOptions.ReplaceAdjustmentAction = TextReplaceOptions.ReplaceAdjustment.WholeWordsHyphenation;
pdfContentEditor.TextEditOptions.ToAttemptGetUnderlineFromSource = true;
// Replace text on all pages
pdfContentEditor.ReplaceText(sentence, pageNo, newText);
Please do the needful and it is quite urgent.
Please let me know if you need any other details.
Thank you
We managed to replicate the said issues in our environment. It has been logged under the ticket ID PDFNET-44488 in our bug tracking system. We have linked your post to this ticket and will keep you informed regarding any available updates.
I have one more issue, text is overlapping with next word or link when the replace text is performed. I have attached the screenshot taken after replacing text.
I’m using the same pdf as above and code is also same.
We have tested your scenario with the latest version 18.4 of Aspose.PDF for .NET API, and could not replicate the problem of overlapping text in our environment. However, we can find the problem of displaced underline of the text. It has been logged under the ticket ID PDFNET-44505 in our bug tracking system. We have linked your post to this ticket and will keep you informed regarding any available updates. This is the output PDF: Output18.4.pdf (587.6 KB)
In reference to the ticket ID PDFNET-44505,
If i replace the text with long string it is going of the page, please refer the attachment. (For example : “ICC” is replaced with “International Cricket Council”)
Same code and same PDF file has been used.
We have recorded this information under the same ticket ID PDFNET-44505 and let you know once a significant progress has been made in this regard. In reference to the linked ticket ID PDFNET-44488, it is pending for the analysis and not resolved yet. It is difficult to share an estimate before the completion of the analysis phase.
I have one more issue, after replacing the text is overlapping with next words, please refer the attachment for the output. I have replaced “Dhoni” with “DhoniMSD”. Replace_Text_Fragment.png (127.6 KB)
// Create TextAbsorber object to find all instances of the input search phrase
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(@"(?i)" + Regex.Escape(sentence), new TextSearchOptions(true));
// Accept the absorber for all the pages
Pdfdocument.Pages[pageNo].Accept(textFragmentAbsorber);
// Get the extracted text fragments
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
// Loop through the fragments
foreach (TextFragment textFragment in textFragmentCollection)
{
foreach (TextSegment textSegment in textFragment.Segments)
{
if (textSegment.Text.ToLower() == originalText.ToLower())
{
textSegment.Text = newText;
}
}
}
if (textFragmentCollection.Count > 0)
{
Pdfdocument.ProcessParagraphs();
Pdfdocument.Save(FileName);
}
We managed to replicate the problem of text overlapping in our environment. It has been logged under the ticket ID PDFNET-44550 in our bug tracking system. We have linked your post to this ticket and will keep you informed regarding any available updates.
The linked ticket IDs PDFNET-44550, PDFNET-44505 and PDFNET-44488 are pending for the analysis and not resolved yet. We will investigate as per the development schedules, and notify you regarding each fix.