Replacing with multiline text not rearranging remaining content

Hi,
my ASPOSE PDF .NET version is 8.2, I am searching a single word/text in pdf and replacing this with multiline text, when I generate final PDF the multiline text is overlapping with existing text on that pdf, is there any way I can fix this? I want to rearrange the remaining text after I replace with multiline text, I downloaded the sample aspose.pdf for .NET project and executed method “rearrangecontentusingtextreplacement.run()”, the generated pdf file is no different than original and I also don’t understand what’s the meaning of this below code there

TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("[Cname,companyname,Textbox,50]");

Please clarify.

@saan123,
In the constructor of the TextFragmentAbsorber class, you need to define a text string which you are seeking to replace. It appears as you did not change the search text string, and get the same output PDF document. There are various ways to search and replace text in the PDF document. Please refer to this help topic: Replace Text in a PDF Document. Kindly send us your source PDF document along with the old and new text strings. We will investigate and share our findings with you.

I defined the text string which I am seeking to replace in TextFragmentAbsorber constructor. It replaces that with new text, no issue but when I place a long text it’s not going to next line rather going in a straight line cutting itself horizontally at page end, please check the input and output file attached.

below is the code

string ExtractedText = “High Performance Computing most generally refers to the practice of aggregating computing power in a way that delivers much higher performance than one could get out of a typical desktop computer or workstation in order to solve large problems in science, engineering, or business.”;

Document doc1 = new Document(“input_file.pdf”);
TextFragmentAbsorber textFragmentAbsorber1 = new TextFragmentAbsorber(“Text Only”);
doc1.Pages.Accept(textFragmentAbsorber1);

foreach (TextFragment txtFragment in textFragmentAbsorber1.TextFragments)
{
txtFragment.TextState.Font = FontRepository.FindFont(“Helvetica”);
txtFragment.TextState.FontSize = 8;
txtFragment.Text = ExtractedText;
}

// Save resultant PDF
doc1.Save(“output_TextFragmentAbsorber.pdf”);

Thanks.

Input_File.pdf (164.0 KB)

output_TextFragmentAbsorber.pdf (187.4 KB)

@saan123,
Please note, PDF is a fixed file format and the other elements do not move after the replacement of text strings. However, in your scenario, the text goes outside the boundary of the page and the line break character “\r\n” also does not work. We have logged an enhancement ticket under the ticket ID PDFNET-43416 in our bug tracking system. We have linked your post to this ticket and will keep you informed regarding any available updates.

Is this issue fixed?? I am also seeking solution for the same problem.

1 Like

@rajpratha

Thank you for contacting support.

We would like to update you that PDFNET-43416 was logged as a feature request to support line breaks while replacing text. It has not been scheduled yet owing to previously logged and critical tickets. It will be scheduled on its due turn which can take some more months. We will let you know as soon as the feature will be supported. We appreciate your patience and comprehension in this regard.

Is this issue fixed?? I am also seeking solution for the same problem.

@jitendra1

We are afraid this ticket has not been scheduled yet. We have recorded your concerns and will notify you as soon as it will be resolved. We appreciate your patience and comprehension in this regard.

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan