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

Free Support Forum - aspose.com

Textfragment absorber

Hello,

I am using following code to generate document and then replace text. But some white space is remaining in between number and replaced fragment.

Could you please provide me solution for the same.

LatexLoadOptions latexLoadOptions = new LatexLoadOptions();

Document doc = new Document("…/…/LatexDocs/English/ComputedQuants/BrakingDistance.tex", latexLoadOptions);



//Document doc = new Document("…/…/LatexDocs/input.tex", latexLoadOptions);



//doc.Save("…/…/output/GeneralExplnations.pdf");

//doc.Save("…/…/output/merged.pdf");



doc.Save(path+"/BrakingDistance.pdf");





TextFragmentAbsorber fragmentAbsorber = new TextFragmentAbsorber(“HeaderBrakingDistance”)

{

TextReplaceOptions =

{

ReplaceAdjustmentAction = TextReplaceOptions.ReplaceAdjustment.AdjustSpaceWidth

}



have a look at pdfs attached

};

doc.Pages.Accept(fragmentAbsorber);



foreach (TextFragment fragment in fragmentAbsorber.TextFragments)

{

fragment.Text = “Braking distance”;

}

doc.Save(path+"/BrakingDistance_Replaced.pdf");

Hi Ranjeeta,


Thanks for contacting supporting.

Please use following code snippet to fix the issue. I have also attached the resultant PDF file for your reference.

<b style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>C#

Document doc = new Document(dataDir + “BrakingDistance.pdf”);
TextFragmentAbsorber fragmentAbsorber = new TextFragmentAbsorber(“HeaderBrakingDistance”);
doc.Pages.Accept(fragmentAbsorber);
foreach (TextFragment fragment in fragmentAbsorber.TextFragments)
{
fragment.Text = “Braking distance”;
}
doc.Save(dataDir + “/BrakingDistance_Replaced1.pdf”);

If you still face any issue or need further assistance, please feel free to contact us.

Best Regards,