By Date: <-- -->
By Thread: <-- -->

Extra blank page at end of document.



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: itext-questions-bounces@lists.sourceforge.net 
> [mailto:itext-questions-bounces@lists.sourceforge.net] On 
> Behalf Of Musolino Fabien
> Sent: Monday, October 30, 2006 10:24 AM
> To: itext-questions@lists.sourceforge.net.
> 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
> 
> fabien.musolino@ne.ch
> 
> -------------------------------------------------------
> 
>  
> 
> 


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
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions