llx is "lower left x" and urx is "upper right x". ColumnText will normalize the values so that they represent a rectangle. About the alignments check your rectangle values, a good exercise is to actually draw a rectangle using the same coordinates to make sure that the rectangle is really where you thing it is. Just another note, you're setting the leading to zero, that means that if you have more than one line they'll be on top of one another.
Paulo ----- Original Message ----- From: "Abhishek Srivastava" <[EMAIL PROTECTED]> To: "Post all your questions about iText here" <[email protected]> Sent: Thursday, August 10, 2006 8:28 PM Subject: Re: [iText-questions] SetSimpleColumn Question > If I change my code to > > float[] pos1 = new float[] { 205, 426, 400, 20 }; > float[] pos2 = new float[] { 205, 375, 400, 50 }; > float[] pos3 = new float[] { 205, 354, 400, 20 }; > > then I get the result I want. But this is confusing because the api says > that setSimpleColumn(llx, lly, urx, ury). > > but the api seems to be working like (llx, lly, width, height); > > Is this understanding correct? > > The second issue is about creating multiple ColumnTexts. > > float[] pos1 = new float[] { 205, 426, 405, 20 }; > float[] pos3 = new float[] { 650, 75, 50, 20 }; > ColumnText ct = new ColumnText(cb); > AddColumnText(cb, "test2", pos1, f); > AddColumnText(cb, "test3", pos3, f); > > where the AddColumnText method is > > private static void AddColumnText( PdfContentByte cb, string text, float[] > pos, Font f) > { > ColumnText ct = new ColumnText(cb); > ct.SetSimpleColumn(pos[0], pos[1], pos[2], pos[3], 0, Element > .ALIGN_CENTER); > Chunk c = new Chunk(text, f); > ct.AddText(c); > ct.Go(); > } > > * the string test2 appears in its rectangle but is not aligned to the > center > of the rectangle. > * the string test3 appears outside its rectange. (under the text test2). > > How can I get each text in its respective rectangle and properly aligned? > > regards, > Abhishek. > > On 8/10/06, Abhishek Srivastava <[EMAIL PROTECTED]> wrote: > >> I have written the following code >> >> BaseFont arial = BaseFont.CreateFont(@"C:\WINDOWS\FONTS\ARIAL.TTF" , >> BaseFont.CP1252, BaseFont.NOT_EMBEDDED); >> Font f = new Font(arial, 10f, Font .NORMAL); >> Document doc = new Document (PageSize.A4.Rotate()); >> PdfWriter writer = PdfWriter .GetInstance(doc, new FileStream( >> @"..\..\test3.pdf" , FileMode.Create)); >> doc.Open(); >> PdfContentByte cb = writer.DirectContent; >> float[] pos1 = new float[] { 205, 426, 644, 446 }; >> float[] pos2 = new float[] { 205, 375, 644, 425 }; >> float[] pos3 = new float[] { 205, 354, 644, 374 }; >> AddColumnText(cb, "POS1 ", pos1, f); >> AddColumnText(cb, "POS2 ", pos2, f); >> AddColumnText(cb, "POS3 ", pos3, f); >> doc.Close(); >> >> The AddColumnText method is >> >> private static void AddColumnText( PdfContentByte cb, string text, >> float[] >> pos, Font f) >> { >> ColumnText ct = new ColumnText(cb); >> ct.SetSimpleColumn(pos[0], pos[1], pos[2], pos[3], 0, Element >> .ALIGN_BOTTOM); >> Chunk c = new Chunk(text, f); >> ct.AddText(c); >> ct.Go(); >> } >> >> When I run this code the gap between POS1, and POS2 is very less. but the >> gap between POS2 and POS3 is large. I do not understand this behaviour >> because the rectange for POS3 is just 20 points and since the text is >> aligned to the bottom, the gap between POS2 and POS3 should be less. POS1 >> and POS2 should have a lot of gap because the height of rectangle for >> POS2 >> is 50 pixels. >> >> What is going on? >> >> regards, >> Abhishek. >> > -------------------------------------------------------------------------------- > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job > easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 -------------------------------------------------------------------------------- > _______________________________________________ > iText-questions mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/itext-questions > ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions
