float[] pos2 = new float[] { 205, 375, 400, 50 };
float[] pos3 = new float[] { 205, 354, 400, 20 };
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 codeBaseFont 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
