Horizontal Alignment issue when Replacing Text

I’m having a problem where my document has a textbox with the text alignment set to justify.


I then run a process where I replace some text

Aspose.Pdf.Facades.PdfContentEditor pdfContentEditor = new Aspose.Pdf.Facades.PdfContentEditor();
pdfContentEditor.BindPdf(profileDocument);
pdfContentEditor.ReplaceTextStrategy.ReplaceScope = Aspose.Pdf.Facades.ReplaceTextStrategy.Scope.REPLACE_ALL;
//replace text on all pages
pdfContentEditor.ReplaceText(“FirstName”, firstName);
pdfContentEditor.Save(userProfilePath);

The resulting output has replaced the text but now the text is left justified.

I’ve tried the same thing without the facade and using the text fragments with the same results as documented here: Replace Text in PDF|Aspose.PDF for Java

What I really want to accomplish here is just the text replacement (which works fine) but I want it to leave the existing formatting and alignment alone.

I’ve attached the document I’m using and you can see the issue on page 6. Notice the text is set to “Justify” and aligns both left and right when you open the document but after doing the text replacement the paragraphs under “Golf Temperament” are now left aligned.

Hi Brad,


Thanks
for using our API’s.
<o:p></o:p>

I
have tested the scenario and I am able to notice the same problem. For the sake
of correction, I have logged this problem as PDFNEWNET-38440 in
our issue tracking system. We will further look into the details of this
problem and will keep you updated on the status of correction. Please be
patient and spare us little time. We are sorry for this inconvenience.

I appreciate the response and confirmation of the problem but I’ve dug through the forums and noticed someone else pointed out this issue in November of last year and ticket PDFREP-33479 was created but no updates to the thread have been posted. I am not going to be able to delay the business need for > 4 months on this issue. Is there any work around I can use or an update to the previous ticket that might resolve this issue?

Hi Brad,


Thanks for sharing the details.

The issue PDFREP-33479 is related to Aspose.Pdf for Reporting Services, which is a rendering extension for SQL Reporting Services and this problem is related to Textbox with Justify not working when text contains a parameter. Please note that Aspose.Pdf for .NET and Aspose.Pdf for Reporting Services are separate components and your problem is related to Aspose.Pdf for .NET.

Util or unless we have evaluated the issue in details, I am afraid we might not be able to share any workaround for this problem. However as soon as we have some definite progress towards its resolution, we will let you know.

Okay thanks.

The issues you have found earlier (filed as PDFNET-38440) have been fixed in Aspose.PDF for .NET 22.6.