  | 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
|
|
|
  | | | i18n approach to footer "Page X of Y " | i18n approach to footer "Page X of Y " 2006-08-01 - By Paul Littlefield
Back In the page events examples
http://itextdocs.lowagie.com/tutorial/directcontent/pageevents/index.htm l#examples
there is an example of printing a footer with text for page numbers as in "Page X of Y".
http://itextdocs.lowagie.com/examples/com/lowagie/examples/directcontent /pageevents/PageNumbersWatermark.java
The code is not internationalized here and I don't see a way to do it as the output string is built dynamically from different event handlers. The "Page X of" text is built for each page in the onEndPage() method. Then the string is augmented in the onCloseDocument() method with the total page count.
Any advice on how to do this using an internationalized approach? For example:
Object[] args = { new Integer(1), new Integer(3) };
String pageXofY = MessageBundle.getString("pageXofY");
MessageFormat format = new MessageFormat(getString(key), _locale);
String localizedString = format.format(args);
In my message.properties file:
pageXofY = Page {0} of {1}
In the meantime I'll just list the page numbers as "Page X" and drop the "of Y" part.
Thanks!
-Paul
<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas -microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">
<head> <meta http-equiv=Content-Type content="text/html; charset=us-ascii"> <meta name=Generator content="Microsoft Word 11 (filtered medium)"> <style> <!-- /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0in; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman";} a:link, span.MsoHyperlink {color:blue; text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline;} span.EmailStyle17 {mso-style-type:personal-compose; font-family:Arial; color:windowtext;} @(protected) Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in;} div.Section1 {page:Section1;} --> </style>
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'>In the page events examples <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-indent:.5in'><font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>http://itextdocs.lowagie.com /tutorial/directcontent/pageevents/index.html#examples<o:p></o:p></span></font>< /p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'>there is an example of printing a footer with text for page numbers as in "Page X of Y". <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-indent:.5in'><font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>http://itextdocs.lowagie.com /examples/com/lowagie/examples/directcontent/pageevents/PageNumbersWatermark .java<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'>The code is not internationalized here and I don't see a way to do it as the output string is built dynamically from different event handlers. The "Page X of" text is built for each page in the onEndPage() method. Then the string is augmented in the onCloseDocument() method with the total page count.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'>Any advice on how to do this using an internationalized approach? For example:<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'> <font color=blue><span style='color:blue'>Object[] args = { new Integer(1), new Integer(3) };<o:p></o :p></span></font></span></font></p>
<p class=MsoNormal><font size=2 color=blue face=Arial><span style='font-size: 10.0pt;font-family:Arial;color:blue'> String pageXofY = MessageBundle.getString(“pageXofY”);<o:p></o:p></span>< /font></p>
<p class=MsoNormal><font size=2 color=blue face=Arial><span style='font-size: 10.0pt;font-family:Arial;color:blue'>   ;MessageFormat format = new MessageFormat(getString(key), _locale);<o:p></o:p></span></font>< /p>
<p class=MsoNormal><font size=2 color=blue face=Arial><span style='font-size: 10.0pt;font-family:Arial;color:blue'> String localizedString = format.format(args);<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'>In my message.properties file:<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-indent:.5in'><font size=2 color=blue face=Arial> <span style='font-size:10.0pt;font-family:Arial;color:blue'>pageXofY = Page {0} of {1}<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'>In the meantime I'll just list the page numbers as "Page X" and drop the "of Y" part.<o:p></o:p></span></font> </p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'>Thanks!<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'>-Paul<o:p></o:p></span></font></p>
</div>
</body>
</html>
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV __ ____ ____ ____ ____ ____ ____ ____ ____ ____ iText-questions mailing list iText-questions@(protected) https://lists.sourceforge.net/lists/listinfo/itext-questions
|
|
 |