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
JSP - A mailing list about Java Server Pages specification and reference
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
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
Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
   MESSAGE
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
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
 
-none-

-none-

2007-09-10       - By rpaquett@(protected)

 Back
Hi Bruno and Paul,

I have this code that produces an onEndPage event (i.e. putting the page
number) on each page.  But now I need a signature block and everything,
anyway the question is:  With this void method, how can I get a reference
to my request?  I need to instantial words in the correct language, etc...

maybe this a bit more of a JAva question than iText, but I just don't
understand how the onEndPage works with only two parameters

With this void method, how can I get a reference to my request?

public class PdfPageSignature extends PdfPageEventHelper {

       /**
        * @(protected)
com.lowagie.text.pdf.PdfPageEventHelper#onEndPage(com.lowagie.text.pdf
.PdfWriter,
com.lowagie.text.Document)
        */
       public void onEndPage(PdfWriter writer, Document document) {

               MessageResources messageResources = (MessageResources)
request.getAttribute(Globals.MESSAGES_KEY);
               HROnlineLocale hrOnlineLocale = new
HROnlineLocale(request);
               try {
                       Rectangle page = document.getPageSize();
                       String text = "page "+ writer.getPageNumber();
                       String employeeInitials =
messageResources.getMessage(hrOnlineLocale.getLocaleLocale(),
"label.employee.initials");
                       PdfPTable footer = new PdfPTable(2);

                       PdfPCell footerCellRight = new PdfPCell(new
Phrase(text,PdfUtils.getBlack(9)));
                       footerCellRight.setBorder(0);
                       footerCellRight.setHorizontalAlignment(2);

                       PdfPCell footerCellLeft = new PdfPCell(new
Phrase(employeeInitials,PdfUtils.getBlack(9)));
                       footerCellLeft.setBorder(0);
                       footerCellLeft.setHorizontalAlignment(0);  

                       footer.addCell(footerCellLeft);
                       footer.addCell(footerCellRight);
                       footer.setTotalWidth(page.width() -
document.leftMargin() - document.rightMargin());
                       footer.writeSelectedRows(0, -1,
document.leftMargin(), document.bottomMargin(),writer.getDirectContent());

               }
               catch (Exception e) {
                       throw new ExceptionConverter(e);
               }
       }
}

R?mi R. Paquette
Developer
Tel: (613) 748-4041
Email: rpaquett@(protected)
700 Montreal Road, Ottawa, Ontario, K1A 0P7
Canada Mortgage and Housing Corporation (CMHC)
http://www.cmhc.ca
R?mi R. Paquette
D?veloppeur
T?l?phone : (613) 748-4041
Courriel : rpaquett@(protected)
700 chemin Montr?al, Ottawa (Ontario) K1A 0P7
Soci?t? canadienne d'hypoth?ques et de logement (SCHL)
http://www.schl.ca




<br><font size=2 face="sans-serif">Hi Bruno and Paul,</font>
<br>
<br><font size=2 face="sans-serif">I have this code that produces an onEndPage
event (i.e. putting the page number) on each page. &nbsp;But now I need
a signature block and everything, anyway the question is: &nbsp;With this
void method, how can I get a reference to my request? &nbsp;I need to instantial
words in the correct language, etc... </font>
<br><font size=2 face="sans-serif">maybe this a bit more of a JAva question
than iText, but I just don't understand how the onEndPage works with only
two parameters</font>
<br>
<br><font size=2 face="sans-serif">With this void method, how can I get
a reference to my request? </font>
<br>
<br><font size=2 color=#820040 face="Courier New"><b>public</b></font><font
size=2 face="Courier New">
</font><font size=2 color=#820040 face="Courier New"><b>class</b></font><font
size=2 face="Courier New">
PdfPageSignature </font><font size=2 color=#820040 face="Courier New"><b
>extends</b></font><font size=2 face="Courier New">
PdfPageEventHelper {</font>
<br>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; </font><font
size=2 color=#4040c2 face="Courier New">/**</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</font>
<font size=2 color=#4040c2 face="Courier New">*</font><font size=2 face="Courier
New">
</font><font size=2 color=#71b2cf face="Courier New"><b>@(protected)</b></font><font
size=2 face="Courier New">
</font><font size=2 color=#4040c2 face="Courier New">com.lowagie.text.pdf
.PdfPageEventHelper#onEndPage(com.lowagie.text.pdf.PdfWriter,</font><font size=2
face="Courier New">
</font><font size=2 color=#4040c2 face="Courier New">com.lowagie.text.Document)
</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</font>
<font size=2 color=#4040c2 face="Courier New">*/</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; </font><font
size=2 color=#820040 face="Courier New"><b>public</b></font><font size=2 face=
"Courier New">
</font><font size=2 color=#820040 face="Courier New"><b>void</b></font><font
size=2 face="Courier New">
onEndPage(PdfWriter writer, Document document) {</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; MessageResources messageResources = (MessageResources)
request.getAttribute(Globals.MESSAGES_KEY);</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; HROnlineLocale hrOnlineLocale = </font><font size=2 color=
#820040 face="Courier New"><b>new</b></font><font size=2 face="Courier New">
HROnlineLocale(request);</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </font><font size=2 color=#820040 face="Courier New"><b
>try</b></font><font size=2 face="Courier New">
{</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Rectangle
page = document.getPageSize();</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; String
text = </font><font size=2 color=#4200ff face="Courier New">&quot;page
&quot;</font><font size=2 face="Courier New">+ writer.getPageNumber();</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; String
employeeInitials = messageResources.getMessage(hrOnlineLocale.getLocaleLocale(),
</font><font size=2 color=#4200ff face="Courier New">&quot;label.employee
.initials&quot;</font><font size=2 face="Courier New">);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PdfPTable
footer = </font><font size=2 color=#820040 face="Courier New"><b>new</b></font>
<font size=2 face="Courier New">
PdfPTable(2);</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PdfPCell
footerCellRight = </font><font size=2 color=#820040 face="Courier New"><b>new<
/b></font><font size=2 face="Courier New">
PdfPCell(</font><font size=2 color=#820040 face="Courier New"><b>new</b></font>
<font size=2 face="Courier New">
Phrase(text,PdfUtils.getBlack(9)));</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; footerCellRight.setBorder(0);<
/font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; footerCellRight
.setHorizontalAlignment(2);</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PdfPCell
footerCellLeft = </font><font size=2 color=#820040 face="Courier New"><b>new</b
></font><font size=2 face="Courier New">
PdfPCell(</font><font size=2 color=#820040 face="Courier New"><b>new</b></font>
<font size=2 face="Courier New">
Phrase(employeeInitials,PdfUtils.getBlack(9)));</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; footerCellLeft.setBorder(0);<
/font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </font><font size=2 color=blue
face="Courier New">footerCellLeft</font><font size=2 face="Courier New">
.setHorizontalAlignment(0);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; footer.addCell(footerCellLeft)
;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; footer.addCell(footerCellRight
);
&nbsp; &nbsp; &nbsp; &nbsp;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; footer.setTotalWidth(page
.width()
- document.leftMargin() - document.rightMargin());</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; footer.writeSelectedRows(0,
-1, document.leftMargin(), document.bottomMargin(),writer.getDirectContent());
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; }</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </font><font size=2 color=#820040 face="Courier New"><b
>catch</b></font><font size=2 face="Courier New">
(Exception e) {</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </font><font size=2 color=
#820040 face="Courier New"><b>throw</b></font><font size=2 face="Courier New">
</font><font size=2 color=#820040 face="Courier New"><b>new</b></font><font
size=2 face="Courier New">
ExceptionConverter(e);</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; }</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; }</font>
<br><font size=2 face="Courier New">}</font><font size=2 face="sans-serif"><br>
</font>
<hr>
<table width=100%>
<tr valign=top>
<td width=46%><font size=1 face="Arial"><b>R?mi R. Paquette</b><br>
Developer<br>
Tel: (613) 748-4041<br>
Email: </font><a href="mailto:rpaquett@(protected)"><font size=1 color=blue
face="Arial"><u>rpaquett@(protected)</u></font></a><font size=1 face="Arial
">
<br>
700 Montreal Road, Ottawa, Ontario, K1A 0P7 <br>
Canada Mortgage and Housing Corporation (CMHC)</font><font size=1 color=blue
face="Arial"><u><br>
</u></font><a href=http://www.cmhc.ca/><font size=1 color=blue face="Arial"><u
>http://www.cmhc.ca</u></font></a><font size=1 face="Arial">
</font>
<td width=53%><font size=1 face="Arial"><b>R?mi R. Paquette</b><br>
D?veloppeur <br>
T?l?phone : (613) 748-4041<br>
Courriel : </font><a href="mailto:rpaquett@(protected)"><font size=1 color
=blue face="Arial"><u>rpaquett@(protected)</u></font></a><font size=1 face=
"Arial">
<br>
700 chemin Montr?al, Ottawa (Ontario) K1A 0P7 <br>
Soci?t? canadienne d'hypoth?ques et de logement (SCHL)</font><font size=1 color
=blue face="Arial"><u><br>
</u></font><a href=http://www.schl.ca/><font size=1 color=blue face="Arial"><u
>http://www.schl.ca</u></font></a><font size=1 face="Arial">
</font></table>
<br>
<p><font size=3>&nbsp; </font>
<p>
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -----
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
__ ____ ____ ____ ____ ____ ____ ____ ____ ____
iText-questions mailing list
iText-questions@(protected)
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

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