TextAlign does not seem to work

TextAlign does not seem to work

Forum member · Apr 7, 2009
Hi all: When I add a Label page element to a PDF Page, they all appear to be Left Aligned; regardless of the alignment which I set. I have even tried the extreme you see below where I have a Case statement to set the alignment right in the constructor. Does anyone have any suggestions on this? I have the following code snippet: Select Case oTextEntry.Alignment Case ensurPDF.ALIGN_CENTER peLabel = New ceTe.DynamicPDF.PageElements.Label( _ oTextEntry.TextPhrase, dX, dY, dWidth, _ oTextEntry.FontSize + 1, _ fntCETE, oTextEntry.FontSize, _ ceTe.DynamicPDF.TextAlign.Center, _ New ceTe.DynamicPDF.WebColor(oTextEntry.FontColor)) Case ensurPDF.ALIGN_LEFT peLabel = New ceTe.DynamicPDF.PageElements.Label( _ oTextEntry.TextPhrase, dX, dY, dWidth, _ oTextEntry.FontSize + 1, _ fntCETE, oTextEntry.FontSize, _ ceTe.DynamicPDF.TextAlign.Left, _ New ceTe.DynamicPDF.WebColor(oTextEntry.FontColor)) Case ensurPDF.ALIGN_RIGHT peLabel = New ceTe.DynamicPDF.PageElements.Label( _ oTextEntry.TextPhrase, dX, dY, dWidth, _ oTextEntry.FontSize + 1, _ fntCETE, oTextEntry.FontSize, _ ceTe.DynamicPDF.TextAlign.Right, _ New ceTe.DynamicPDF.WebColor(oTextEntry.FontColor)) End Select Thanks, Matt

Re: TextAlign does not seem to work

Support · Apr 7, 2009
Hello Matt, We are able to set the alignment to the labels without any problem. Please make sure that you are setting it properly. Below is a sample code which sets right alignment. Please try running the below sample code. Document document = new Document(); Page page = new Page(); Label label = new Label("Text Right aligned", 100, 350, 200, 20, Font.HelveticaBold, 12, TextAlign.Right, RgbColor.Blue); page.Elements.Add(label); document.Pages.Add(page); document.Draw(@"C:\Temp\RightAlign.pdf"); Thanks, ceTe Software Support Team.

Re: TextAlign does not seem to work

Forum member · Apr 7, 2009
When I place a breakpoint in the code, the "Center" case is executed and the resulting Label has all of the correct properties. I called the routine and had it generate one Label of each alignment (Left, Center, and Right). The resulting PDF had them all Left aligned. I have searched your Forums and the web and have not seen anyone that is having this problem. I'm thinking that I'm doing something wrong somewhere...but it's driving me nuts! - Matt

Re: TextAlign does not seem to work

Support · Apr 7, 2009
Hello Matt, The code that you are using seems to be fine. Are you setting the case for the alignment using any static variable? That could be causing this behavior. Try displaying one label at a time and see if each case displays correctly. Thanks, ceTe Software Support Team

Re: TextAlign does not seem to work

Forum member · Apr 7, 2009
Figured out the problem. The PDF which I was using was landscape and the label was rotated 270 degrees. The alignment property works fine when the label is not rotated.