You are using Table and that's not supported anymore but some good soul may 
have provided a fix in the latest release. Use PdfPTable to make sure it will 
work. 

Paulo 

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Musolino Fabien
> Sent: Monday, October 30, 2006 10:24 AM
> To: [EMAIL PROTECTED]
> Subject: [iText-questions] Extra blank page at end of document.
> 
> Hi all.
> 
> I’m trying to create a PDF document using iText 1.4.2.
> 
> I would like to add a special footer at the end of document.
> 
> I already addes the “Page x on y” stuff and it’s working fine.
> 
> My special footer also prints but on a blank page.
> 
> If my document has only one page, everything’s ok. If it has 
> more than one page, the footer “creates” an extra page just for it.
> 
> I followed the recommendation saying that theses footer 
> things should be placed in the onEndPage event.
> 
> In this document, I’m trying to create a table
> 
> Here’s the code of the table :
> 
>  
> 
>                           //An object creating our standard table
> 
>                PDFStandardTable tablePoursuites = new 
> PDFStandardTable(100);
> 
>                tablePoursuites.setPadding(1);
> 
>                tablePoursuites.setSpaceBetweenCells(0);
> 
>                tablePoursuites.setCellsFitPage(true);
> 
>                
> tablePoursuites.addColumn(7,PDFStandardTable.ALIGN_CENTER,"N° doss.");
> 
>                
> tablePoursuites.addColumn(7,PDFStandardTable.ALIGN_CENTER,"N° série");
> 
>                tablePoursuites.addColumn(39,"Représentant du 
> créancier\nCréancier");
> 
>                
> tablePoursuites.addColumn(8,PDFStandardTable.ALIGN_RIGHT,"Créa
> nce\nRésultat");
> 
>                
> tablePoursuites.addColumn(8,PDFStandardTable.ALIGN_RIGHT,"Sold
> e\nPerte");
> 
>                
> tablePoursuites.addColumn(1,PDFStandardTable.ALIGN_RIGHT,"");
> 
>                tablePoursuites.addColumn(30,"Etat\nRéférence 
> créancier");
> 
>                tablePoursuites.setLastHeaderRow(1);
> 
>                tablePoursuites.prepareTableLines();
> 
>              //Adds a title to the table
> 
>              
> tablePoursuites.addColspanedLine(PDFStandardValues.boldItalicF
> ont, "Poursuites", Element.ALIGN_LEFT);
> 
>              //Adds the headres
> 
>                
> tablePoursuites.addHeadersLine(PDFStandardValues.boldFontSmall);
> 
>                if 
> (virtualSituationBean.getDebtorRequisitionsListSize() == 0){
> 
>                     //Message if nothing to display
> 
>                     
> tablePoursuites.addColspanedLine(PDFStandardValues.normalFontS
> mall, "Pas de poursuites.", Element.ALIGN_CENTER);
> 
>                } else {
> 
>                     //Adds th values
> 
>                    for (SimpleVirtualCreditBean current : 
> virtualSituationBean.getDebtorRequisitionsList()) {
> 
>                    
> tablePoursuites.addValuesLine(PDFStandardValues.normalFontSmal
> l, new String[]{current.getNumeroDossier(), 
> current.getNumeroSerie(), current.getRepresentantCreancier(), 
> current.getCreance(), current.getSoldeRestant(), "", 
> current.getEtat()});
> 
>                    
> tablePoursuites.addValuesLine(PDFStandardValues.normalFontSmal
> l, new String[]{"", "",  current.getCreancier(), 
> current.getResultat(), current.getPerte(), "", 
> current.getReferenceCreancier()});
> 
>                    }
> 
>                     //Adds the total
> 
>                    
> tablePoursuites.addTotalsLine(PDFStandardValues.boldFontSmall,
>  new String[]{"", "", "", 
> Tools.getBetragAsString(virtualSituationBean.getPoursuitesTota
> lCreance(),false,true), 
> Tools.getBetragAsString(virtualSituationBean.getPoursuitesTota
> lSoldeRestant(),false,true), "", ""});
> 
>                    
> tablePoursuites.addTotalsLine(PDFStandardValues.boldFontSmall,
>  new String[]{"", "", "", 
> Tools.getBetragAsString(virtualSituationBean.getPoursuitesTota
> lResultat(),false,true), 
> Tools.getBetragAsString(virtualSituationBean.getPoursuitesTota
> lPerte(),false,true), "", ""});
> 
>                }
> 
>             document.add(tablePoursuites);
> 
>  
> 
>  
> 
> Here’s the code for the events :
> 
>  
> 
>     public void onOpenDocument(PdfWriter pdfWriter, Document 
> document) {
> 
>        PdfContentByte cb = pdfWriter.getDirectContent();
> 
>              cb = pdfWriter.getDirectContent();
> 
>         tpl = cb.createTemplate(50, 25);
> 
>         tpl.setBoundingBox(new Rectangle(0, 0, 50, 25));
> 
>         try {
> 
>              helv = BaseFont.createFont("Helvetica", 
> BaseFont.WINANSI, false);
> 
>        } catch (DocumentException e) {
> 
>              e.printStackTrace();
> 
>        } catch (IOException e) {
> 
>              e.printStackTrace();
> 
>        }
> 
>     }
> 
>  
> 
>     public void onEndPage(PdfWriter writer, Document document) {
> 
>        PdfContentByte cb = writer.getDirectContent();
> 
>  
> 
>        try {
> 
>              cb.saveState();
> 
>              PDFStandardLibrary.addLightHeader(document, cb, helv);
> 
>              cb.restoreState();
> 
>        } catch (DocumentException e) {
> 
>              e.printStackTrace();
> 
>        }
> 
>  
> 
>         cb.saveState();
> 
>         String text = "Page " + writer.getPageNumber() + " sur ";
> 
>         float textSize = helv.getWidthPoint(text, pageFontSize);
> 
>         float textBase = document.bottom() - 20;
> 
>         cb.beginText();
> 
>         cb.setFontAndSize(helv, pageFontSize);
> 
>         cb.setTextMatrix(document.left(), textBase);
> 
>         cb.showText(text);
> 
>         cb.endText();
> 
>         cb.addTemplate(tpl, document.left() + textSize, textBase);
> 
>         cb.restoreState();
> 
>  
> 
>  
> 
>        BaseFont bf = 
> BaseFont.createFont(BaseFont.HELVETICA_BOLDOBLIQUE, 
> BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
> 
>        float fontSize = 
> PDFStandardValues.boldItalicFont.getCalculatedSize();
> 
>         float imgOffset = 0;
> 
>                            
> 
>         if (this.endOfPageImageName != null && 
> !this.endOfPageImageName.equals("")){
> 
>              Image img = 
> Image.getInstance(Util.getImageAsByteArray(this.endOfPageImage
> Name, service.getFileContext(), GvuDebtEnforcementEnv.APP_NAME));
> 
>              img.scalePercent(this.endOfPageImageScale);
> 
>              float imgWidth = (img.width() * 
> ((float)this.endOfPageImageScale/(float)100));
> 
>              float imgHeight = (img.height() * 
> ((float)this.endOfPageImageScale/(float)100));
> 
>              float x = document.getPageSize().width() - 
> document.rightMargin() - imgWidth;
> 
>              float y = document.bottomMargin() + 
> (bf.getAscentPoint(this.endOfPageText, fontSize) - 
> bf.getDescentPoint(this.endOfPageText, fontSize));
> 
>              cb.saveState();
> 
>              cb.addImage(img, imgWidth, 0, 0, imgHeight, x, y);
> 
>              cb.restoreState();
> 
>         }
> 
>         if (this.endOfPageText != null && 
> !this.endOfPageText.equals("")){
> 
>                     cb.saveState();
> 
>              cb.beginText();
> 
>                cb.setFontAndSize(bf, fontSize);
> 
>                 
> cb.setColorFill(PDFStandardValues.boldItalicFont.color());
> 
>                 
> cb.showTextAligned(PdfContentByte.ALIGN_RIGHT,this.endOfPageTe
> xt,document.getPageSize().width()-document.rightMargin(),docum
> ent.bottomMargin()+imgOffset,0);
> 
>                 cb.endText();
> 
>                cb.restoreState();
> 
>        }
> 
>     }
> 
>  
> 
>     public void onCloseDocument(PdfWriter pdfWriter, Document 
> document) {
> 
>         tpl.beginText();
> 
>         tpl.setFontAndSize(helv, pageFontSize);
> 
>         tpl.setTextMatrix(0, 0);
> 
>         tpl.showText("" + (pdfWriter.getPageNumber() - 1));
> 
>         tpl.endText();
> 
>     }
> 
>  
> 
>  
> 
> Can someone help me ?
> 
> Thank you.
> 
>  
> 
> -------------------------------------------------------
> 
> Fabien Musolino
> 
> Développeur Web (www.ne.ch <http://www.ne.ch> )
> 
> Service du Traitement de l'Information
> 
> Faubourg du Lac 25
> 
> 2000 Neuchâtel
> 
> +41 32 889 84 21
> 
> [EMAIL PROTECTED]
> 
> -------------------------------------------------------
> 
>  
> 
> 


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.

-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to