Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

Horizontal Alignment issue when Replacing Text

$
0
0
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: http://www.aspose.com/docs/display/pdfjava/Replace+Text+in+Pages+of+a+PDF+Document

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. 

Viewing all articles
Browse latest Browse all 3131

Trending Articles