Hi,
Thanks for your patience.
We have further investigated the problem reported earlier and as per our observations, Automatically center alignment is not possible. However it’s possible to center alignment programmatically:
1. compute x coordinate
2. set the text fragment position:
[C#]
//open document<o:p></o:p>
Document pdfDocument = new Document("c:/pdftest/brunokaart.pdf");
//create TextAbsorber object to find
all instances of the input search phrase
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("<>");
//accept the absorber for a particular
page
pdfDocument.Pages[1].Accept(textFragmentAbsorber);
//get the extracted text fragments
TextFragmentCollection textFragmentCollection =
textFragmentAbsorber.TextFragments;
//loop through the fragments
foreach (TextFragment
textFragment in textFragmentCollection)
{
//update text and other properties
textFragment.Text = "This
is a new phrase";
textFragment.TextState.Font = FontRepository.FindFont("Verdana");
textFragment.TextState.FontSize = 16;
textFragment.Position = new
Position(pdfDocument.Pages[1].Rect.LLX +(pdfDocument.Pages[1].Rect.Width - textFragment.Rectangle.Width) / 2,
textFragment.Position.YIndent);
}
pdfDocument.Save(“c:/pdftest/TextReplaceOutput.pdf”);