Re: [iText-questions] PdfWriter.getPageNumber() is returning next page number when table ends at the end of page

2010-04-22 Thread suresh . chennupati
I am using 2.1.3 version. 





Paulo Soares psoa...@glintt.com 
04/21/2010 06:50 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] PdfWriter.getPageNumber() is returning next page 
number when table ends at the end of page






Are you using the latest release?
 
Paulo
- Original Message - 
From: suresh.chennup...@judiciary.state.nj.us 
To: itext-questions@lists.sourceforge.net 
Sent: Wednesday, April 21, 2010 5:49 PM
Subject: [iText-questions] PdfWriter.getPageNumber() is returning next 
page number when table ends at the end of page

I am trying to display mutiple tables in a single PDF and display page X 
of Y 
at the end of each page. 
X, Y should reset for every new table(Basically every new table should 
start 
with a new page.) 
Each table can vary and span accross multiple pages. 

I don't have problem while tables end in the middle of page(1 page of 
multiple pages). 
The problem comes when the table size matches page size. 

If a table size is approximately equal to page size. 
it displays page 1 of 2, when it has only one page. 

For tables ending in the middle of page, if it has 3 pages, page numbers 
are 
displayed correctly as 
1 of 3 , 2 of 3 , 3 of 3. But when table size ends at the end of page, if 
there is 1 page, still it display 1 of 2. 

Please note, the number of data tables is dynamic . 
 
public class DocumentEventListener implements PdfPageEvent { 
PdfTemplate m_Template; 
BaseFont m_BaseFont; 
PdfContentByte m_Cb; 


public void onEndPage(PdfWriter writer, Document arg1) { 
try { 

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(); 
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(); 
} 

} 

public void createNewTemplate(PdfWriter arg0){ 

m_Cb = arg0.getDirectContent(); 
m_Template = m_Cb.createTemplate(85,140); 


} 


public void fillOutTemplate(PdfWriter arg0) { 
try { 
// arg0.reorderPages(null); 
m_BaseFont = 
BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, 
BaseFont.NOT_EMBEDDED); 
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(); 
} catch (DocumentException e) { 
// TODO Auto-generated catch block 
e.printStackTrace(); 
} catch (IOException e) { 
// TODO Auto-generated catch block++ 
e.printStackTrace(); 
} 
} 

} 



 



//Creating template for printing Page X of Y at 
the end of page 
((DocumentEventListener) 
writer.getPageEvent()).createNewTemplate(writer); 
 

document.add(dataTableX); 

document.add(dataTableY); 

//Filling template for printing Page X of Y at the 
end of page 
((DocumentEventListener) 
writer.getPageEvent()).fillOutTemplate(writer); 


Please let me know, if any one has faced similar problem before. 

Thanks 
Suresh Chennupati
--
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
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

Re: [iText-questions] PdfWriter.getPageNumber() is returning next page number when table ends at the end of page

2010-04-22 Thread suresh . chennupati
); 

   document.add(dataTableY); 

   //Filling template for printing Page X of Y at the 
end of page 
   ((DocumentEventListener) 
writer.getPageEvent()).fillOutTemplate(writer); 



Please let me know, if any one has faced similar problem before. 

Thanks 
Suresh Chennupati
--
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
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/ 
Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter 
informação confidencial ou legalmente protegida. A incorrecta transmissão 
desta mensagem não significa a perca de confidencialidade. Se esta 
mensagem for recebida por engano, por favor envie-a de volta para o 
remetente e apague-a do seu sistema de imediato. É proibido a qualquer 
pessoa que não o destinatário de usar, revelar ou distribuir qualquer 
parte desta mensagem. 

Disclaimer:
This message is destined exclusively to the intended receiver. It may 
contain confidential or legally protected information. The incorrect 
transmission of this message does not mean the loss of its 
confidentiality. If this message is received by mistake, please send it 
back to the sender and delete it from your system immediately. It is 
forbidden to any person who is not the intended receiver to use, 
distribute or copy any part of this message.
--
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
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/
--
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
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/

[iText-questions] PdfWriter.getPageNumber() is returning next page number when table ends at the end of page

2010-04-21 Thread suresh . chennupati
I am trying to display mutiple tables in a single PDF and display page X 
of Y 
at the end of each page.   
X, Y should reset for every new table(Basically every new table should 
start 
with a new page.) 
Each table can vary and span accross multiple pages. 

I don't have problem while tables end in the middle of page(1 page of 
multiple pages). 
The problem comes when the table size matches page size. 

If a table size is approximately equal to page size. 
it displays page 1 of 2, when it has only one page. 

For tables ending in the middle of page, if it has 3 pages, page numbers 
are 
displayed correctly as 
1 of 3 , 2 of 3 , 3 of 3. But when table size ends at the end of page, if 
there is 1 page, still it display 1 of 2. 

Please note, the number of data tables is dynamic . 
  
public class DocumentEventListener implements PdfPageEvent { 
PdfTemplate m_Template; 
BaseFont m_BaseFont; 
PdfContentByte m_Cb; 


public void onEndPage(PdfWriter writer, Document arg1) { 
try { 

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(); 
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(); 
} 

} 

public void createNewTemplate(PdfWriter arg0){ 

m_Cb = arg0.getDirectContent(); 
m_Template = m_Cb.createTemplate(85,140); 


} 


public void fillOutTemplate(PdfWriter arg0) { 
try { 
// arg0.reorderPages(null); 
m_BaseFont = 
BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, 
BaseFont.NOT_EMBEDDED); 
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(); 
} catch (DocumentException e) { 
// TODO Auto-generated catch block 
e.printStackTrace(); 
} catch (IOException e) { 
// TODO Auto-generated catch block++ 
e.printStackTrace(); 
} 
} 

} 



 



//Creating template for printing Page X of Y at 
the end of page 
((DocumentEventListener) 
writer.getPageEvent()).createNewTemplate(writer); 


document.add(dataTableX); 

document.add(dataTableY); 

//Filling template for printing Page X of Y at the 
end of page 
((DocumentEventListener) 
writer.getPageEvent()).fillOutTemplate(writer); 

Please let me know, if any one has faced similar problem before.

Thanks
Suresh Chennupati--
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
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/

[iText-questions] Page Number issue, when table ends at the very end of page

2010-04-19 Thread suresh . chennupati
I am trying to display mutiple tables in a single PDF and display page X 
of Y 
at the end of each page. 
X, Y should reset for every new table(Basically every new table should 
start 
with a new page.) 
Each table can vary and span accross multiple pages.

I don't have problem while tables end in the middle of page(1 page of 
multiple pages). 
The problem comes when the table size matches page size. 

If a table size is approximately equal to page size. 
it displays page 1 of 2, when it has only one page. 

For tables ending in the middle of page, if it has 3 pages, page numbers 
are 
displayed correctly as 
1 of 3 , 2 of 3 , 3 of 3. But when table size ends at the end of page, if 
there is 1 page, still it display 1 of 2. 




public class DocumentEventListener implements PdfPageEvent {
PdfTemplate m_Template;
BaseFont m_BaseFont;
PdfContentByte m_Cb;


public void onEndPage(PdfWriter writer, Document arg1) {
try {

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();
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();
}

}

public void createNewTemplate(PdfWriter arg0){

m_Cb = arg0.getDirectContent();
m_Template = m_Cb.createTemplate(85,140);


}


public void fillOutTemplate(PdfWriter arg0) {
try {
//  arg0.reorderPages(null);
m_BaseFont = 
BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, 
BaseFont.NOT_EMBEDDED);
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();
} catch (DocumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block++
e.printStackTrace();
}
}

}






//Creating template for printing Page X of Y at 
the end of page
((DocumentEventListener) 
writer.getPageEvent()).createNewTemplate(writer);
 

document.add(dataTableX);

document.add(dataTableY);

//Filling template for printing Page X of Y at the 
end of page
((DocumentEventListener) 
writer.getPageEvent()).fillOutTemplate(writer);


Please help.--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
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/

[iText-questions] Page Number issue, when table ends at the very end of page

2010-04-19 Thread suresh . chennupati
I am trying to display mutiple tables in a single PDF and display page X 
of Y 
at the end of each page. 
X, Y should reset for every new table(Basically every new table should 
start 
with a new page.) 
Each table can vary and span accross multiple pages.

I don't have problem while tables end in the middle of page(1 page of 
multiple pages). 
The problem comes when the table size matches page size. 

If a table size is approximately equal to page size. 
it displays page 1 of 2, when it has only one page. 

For tables ending in the middle of page, if it has 3 pages, page numbers 
are 
displayed correctly as 
1 of 3 , 2 of 3 , 3 of 3. But when table size ends at the end of page, if 
there is 1 page, still it display 1 of 2. 




public class DocumentEventListener implements PdfPageEvent {
PdfTemplate m_Template;
BaseFont m_BaseFont;
PdfContentByte m_Cb;


public void onEndPage(PdfWriter writer, Document arg1) {
try {

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();
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();
}

}

public void createNewTemplate(PdfWriter arg0){

m_Cb = arg0.getDirectContent();
m_Template = m_Cb.createTemplate(85,140);


}


public void fillOutTemplate(PdfWriter arg0) {
try {
//  arg0.reorderPages(null);
m_BaseFont = 
BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, 
BaseFont.NOT_EMBEDDED);
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();
} catch (DocumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block++
e.printStackTrace();
}
}

}






//Creating template for printing Page X of Y at 
the end of page
((DocumentEventListener) 
writer.getPageEvent()).createNewTemplate(writer);
 

document.add(dataTableX);

document.add(dataTableY);

//Filling template for printing Page X of Y at the 
end of page
((DocumentEventListener) 
writer.getPageEvent()).fillOutTemplate(writer);


Please help.--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
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/

Re: [iText-questions] Page Number problem when table ends at the complete end of the page

2009-09-08 Thread suresh . chennupati
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___