We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Text in not completly displayed after replacement

Hello I am using following code to Absorb and replace text. But complete replaced text is not displayed in final output.





LatexLoadOptions load = new LatexLoadOptions();



Document doc = new Document(path,load);



//doc = SetHeaderFooter(doc);

doc.Save(path1);



TextFragmentAbsorber absorber=new TextFragmentAbsorber(“0.0.1”);

doc.Pages.Accept(absorber);



if (absorber.TextFragments.Count > 0)

absorber.TextFragments[1].Text = “A.B”;

doc.Save(path2);



In pdf I am replacing 0.0.1 with A.B in final output Only B is displayed Not A.



Please refer to attached pdfs.

Hi Sameer,


Thanks for contacting support.

I have tried following code snippet with Aspose.Pdf for .NET 17.4.0, to replace the text inside PDF and was unable to notice the issue.

Document doc = new Document(dataDir + “BrakingRatioDynamic.pdf”);<o:p></o:p>

TextFragmentAbsorber absorber = new TextFragmentAbsorber("0.0.1");

doc.Pages.Accept(absorber);

if (absorber.TextFragments.Count > 0)

absorber.TextFragments[1].Text = "A.B";

doc.Save(dataDir + "BrakingRatioDynamic_out.pdf");



For your reference, I have also attached an output, generated by above code. Please try using latest version of the API and in case if you still face any issue, please share your environment details (i.e OS information, Target Framework, Application Type etc). This way we can try to reproduce the issue in our environment and address it accordingly.

Moreover, you may also try initializing document again after conversion from LaTex. Please check highlighted part in the following code snippet.


LatexLoadOptions load = new LatexLoadOptions();

Document doc = new Document(path, load);

//doc = SetHeaderFooter(doc);

doc.Save(path1);

doc = new Document(path1);

TextFragmentAbsorber absorber = new TextFragmentAbsorber("0.0.1");

doc.Pages.Accept(absorber);

if (absorber.TextFragments.Count > 0)

absorber.TextFragments[1].Text = "A.B";

doc.Save(path2);



Best Regards,

Hello Asad,
I tried above code still it is not working on my side.
As you asked environment details are as follows:

OS Windows 7 enterprise,
Target framework 4.5.2
Application type: Desktop application (WPF).

Thank you,

Hello Sameer,


Thanks for writing back. I have tested the scenario in an environment, specified above, and was unable to notice any issue. The text was replaced just fine and no text overlapping happened in the resultant output file, which I have attached as well for your reference.

Asad Ali:
Moreover, you may also try initializing document again after conversion from LaTex. Please check highlighted part in the following code snippet.


LatexLoadOptions load = new LatexLoadOptions();<o:p></o:p>

Document doc = new Document(path, load);<o:p></o:p>

//doc = SetHeaderFooter(doc);<o:p></o:p>

doc.Save(path1);<o:p></o:p>

doc = new Document(path1);<o:p></o:p>

TextFragmentAbsorber absorber = new TextFragmentAbsorber(“0.0.1”);<o:p></o:p>

doc.Pages.Accept(absorber);<o:p></o:p>

if (absorber.TextFragments.Count > 0)<o:p></o:p>

absorber.TextFragments[1].Text = “A.B”;<o:p></o:p>

doc.Save(path2);


Would you please confirm that if you have tried to re-initialize document after converting from LaTex? In case if you did so and still faced the issue, please share your LaTex file, so that we can test the scenario again in our environment and address it accordingly.


Best Regards,