Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
JSP - A mailing list about Java Server Pages specification and reference
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
SetSimpleColumn Question

SetSimpleColumn Question

2006-08-10       - By Abhishek Srivastava

 Back
Reply:     1     2     3  

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.

<div>I have written the following code</div>
<div><font color="#008080" size="2"><font size="2">
<p></p></font><font color="#008080" size="2">BaseFont</font><font size="2">
arial = </font><font color="#008080" size="2">BaseFont</font><font size="2">
.CreateFont(</font><font color="#800000" size="2">@&quot;C:\WINDOWS\FONTS\ARIAL
.TTF&quot;
</font><font size="2">, </font><font color="#008080" size="2">BaseFont</font>
<font size="2">.CP1252, </font><font color="#008080" size="2">BaseFont</font>
<font size="2">.NOT_EMBEDDED);<br></font><font color="#008080" size="2">
Font</font><font size="2"> f = </font><font color="#0000ff" size="2">new</font>
<font size="2"> </font><font color="#008080" size="2">Font</font><font size="2">
(arial, 10f, </font><font color="#008080" size="2">Font</font>
<font size="2">.NORMAL);<br></font><font color="#008080" size="2">Document<
/font><font size="2"> doc = </font><font color="#0000ff" size="2">new</font>
<font size="2"> </font><font color="#008080" size="2">Document</font><font size=
"2">
(</font><font color="#008080" size="2">PageSize</font><font size="2">.A4.Rotate
());<br></font><font color="#008080" size="2">PdfWriter</font><font size="2">
writer = </font><font color="#008080" size="2">PdfWriter</font><font size="2">
.GetInstance(doc, </font><font color="#0000ff" size="2">new</font><font size="2
"> </font><font color="#008080" size="2">FileStream</font><font size="2">(</font
><font color="#800000" size="2">@&quot;..\..\test3.pdf&quot;</font>
<font size="2">, </font><font color="#008080" size="2">FileMode</font><font
size="2">.Create));<br>doc.Open();<br></font><font color="#008080" size="2"
>PdfContentByte</font><font size="2"> cb = writer.DirectContent;<br></font>
<font color="#0000ff" size="2">float</font><font size="2">[] pos1 = </font>
<font color="#0000ff" size="2">new</font><font size="2"> </font><font color="
#0000ff" size="2">float</font><font size="2">[] { 205, 426, 644, 446 };
<br></font><font color="#0000ff" size="2">float</font><font size="2">[] pos2 =
</font><font color="#0000ff" size="2">new</font><font size="2"> </font><font
color="#0000ff" size="2">float</font><font size="2">[] { 205, 375, 644, 425 };
<br></font><font color="#0000ff" size="2">float</font><font size="2">[] pos3 =
</font><font color="#0000ff" size="2">new</font><font size="2"> </font><font
color="#0000ff" size="2">float</font><font size="2">[] { 205, 354, 644, 374 };
<br>AddColumnText(cb, </font><font color="#800000" size="2">&quot;POS1 &quot;<
/font><font size="2">, pos1, f); <br>AddColumnText(cb, </font><font color="
#800000" size="2">&quot;POS2 &quot;</font><font size="2">, pos2, f);
<br>AddColumnText(cb, </font><font color="#800000" size="2">&quot;POS3 &quot;<
/font><font size="2">, pos3, f);<br>doc.Close();</font></font>
<p><font size="2">The AddColumnText method is </font></p></div>
<div><font size="2">
<p></p></font><font color="#0000ff" size="2">private</font><font size="2"> <
/font><font color="#0000ff" size="2">static</font><font size="2"> </font><font
color="#0000ff" size="2">void</font><font size="2"> AddColumnText(
</font><font color="#008080" size="2">PdfContentByte</font><font size="2"> cb,
</font><font color="#0000ff" size="2">string</font><font size="2"> text, </font>
<font color="#0000ff" size="2">float</font><font size="2">[] pos,
</font><font color="#008080" size="2">Font</font><font size="2"> f)<br>{<br><
/font><font color="#008080" size="2">&nbsp; ColumnText</font><font size="2"> ct
= </font><font color="#0000ff" size="2">new</font><font size="2"> </font>
<font color="#008080" size="2">ColumnText</font><font size="2">(cb); <br>&nbsp;
ct.SetSimpleColumn(pos[0], pos[1], pos[2], pos[3], 0, </font><font color="
#008080" size="2">Element</font><font size="2">.ALIGN_BOTTOM);<br></font>
<font color="#008080" size="2">&nbsp; Chunk</font><font size="2"> c = </font>
<font color="#0000ff" size="2">new</font><font size="2"> </font><font color="
#008080" size="2">Chunk</font><font size="2">(text, f);<br>&nbsp; ct.AddText(c);
<br>&nbsp; ct.Go();<br>}</font>
<p>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.
</p>
<p>What is going on?</p>
<p>regards,<br>Abhishek.</p></div>

-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -----
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
iText-questions@(protected)
https://lists.sourceforge.net/lists/listinfo/itext-questions

©2008 junlu.com - Jax Systems, LLC, U.S.A.