I had implemented your solution:
Sample Code in event listener:
onEndPage(){
final int page = writer.getPageNumber();
String text = "Page " + page;
m_BaseFont = BaseFont.createFont(BaseFont.
HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
m_Cb = writer.getDirectContent();
if(m_Cb!=null){
m_Cb.beginText();
m_Cb.setFontAndSize(m_BaseFont, 8);
m_Cb.showTextAligned(PdfContentByte.
ALIGN_RIGHT,text,410,20,0);
m_Cb.endText();
}
}
Sample code in program:
createNewTemplate(PdfWriter arg0){
try {
m_BaseFont = BaseFont.createFont(BaseFont.
HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
m_Cb = arg0.getDirectContent();
m_Template = m_Cb.createTemplate(85,87);
final int page = arg0.getPageNumber();
String text = "Page " + page;
if(m_Cb!=null){
m_Cb.beginText();
m_Cb.setFontAndSize(m_BaseFont, 8);
m_Cb.showTextAligned(PdfContentByte.
ALIGN_RIGHT,text,410,20,0);
m_Cb.endText();
m_Cb.addTemplate(m_Template, 352.3f, 20);
}
} catch (DocumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
fillOutTemplate(PdfWriter arg0) {
System.out.println("fillOutTemplate:"
+arg0.getPageNumber());
m_Template.beginText();
m_Template.setFontAndSize(m_BaseFont, 8);
String text = "of " + (arg0.getPageNumber() );
m_Template.showTextAligned(PdfContentByte.ALIGN_LEFT,
text, 65, 0, 0);
m_Template.endText();
}
this.createNewTemplate(writer);
document.add(employeesTable);
this.fillOutTemplate(writer);
When this code is executed, it displays page 1 of X in first page, but
page 2 , page 3 in rest of the pages.
When a new table starts it displays againg page 1 of Y, followed by page 2
and page 3.
Please let me know, why template is not filled out at end of every page?
Do i need to use, onChapter & onChapterEnd to fill the template?
Thanks,
Suresh
1T3XT info <i...@1t3xt.info>
09/04/2009 12:14 PM
Please respond to
Post all your questions about iText here
<itext-questions@lists.sourceforge.net>
To
Post all your questions about iText here
<itext-questions@lists.sourceforge.net>
cc
Subject
Re: [iText-questions] Page Number problem when table ends at the complete
end of the page
chennupati wrote:
> I am using ChapterAutoNumber,
Why? It adds complexity to your app,
and it makes your app error prone.
Don't use Chapters, but use document.newPage() every time
you've added a table.
Remove:
> public void onChapter(PdfWriter arg0, Document arg1, float arg2,
> Paragraph arg3) {
> public void onChapterEnd(PdfWriter arg0, Document arg1, float arg2) {
Replace them with normal methods, such as:
public void createNewTemplate()
and
public void fillOutTemplate()
(Or whichever name you think describes best what the method does.)
Call these methods before and after document.newPage().
--
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008
30-Day
trial. Simplify your report design, integration and deployment - and focus
on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list:
http://1t3xt.info/tutorials/keywords/
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/