That behavior is by design. If you place an empty Paragraph with zero leading before the table, the spacing before will always work.
Paulo ----- Original Message ----- From: "Herman Vierendeels" <[EMAIL PROTECTED]> To: <[email protected]> Sent: Friday, October 24, 2008 8:59 PM Subject: [iText-questions] PdfPTable setSpacingBefore not honoured if pdfptable added as first element to document iText-2.1.3 PdfPTable setSpacingBefore not honoured if pdfptable added as first element to document it has something to do with ./core/com/lowagie/text/pdf/PdfDocument.java addPTable() ct.addElement(ptable); ./core/com/lowagie/text/pdf/ColumnText.java adjustFirstLine = true public void setAdjustFirstLine(boolean adjustFirstLine) #but can not reach this method! protected int goComposite() boolean firstPass = adjustFirstLine;//so TRUE too if (element.type() == Element.PTABLE) if (!firstPass && listIdx == 0) {yTemp -= table.spacingBefore();} test source: //export CLASSPATH=/tmp/iText-2.1.3.jar:./ //java brol1 100 paragraphFirst #ok spacing //java brol1 100 #nok no spacing // import java.io.*; import com.lowagie.text.*; import com.lowagie.text.pdf.*; public class brol1 { public static void main(String[] args) throws Exception { int spacingBefore=Integer.valueOf(args[0]); boolean doParagraphFirst=false; if(args.length>1) doParagraphFirst=true; Document.compress=false; System.out.println("version="+Document.getVersion()); Rectangle pageSize=PageSize.A4; Document document=new Document(pageSize); String pdfnm="/tmp/brol1.pdf"; PdfWriter pw=PdfWriter.getInstance(document,new FileOutputStream(pdfnm)); document.open(); PdfPTable table=new PdfPTable(1); table.setSpacingBefore(spacingBefore); PdfPCell cll=new PdfPCell(new Phrase("test")); table.addCell(cll); if(doParagraphFirst) { document.add(new Paragraph(" ")); } document.add(table); document.close(); }//main Thanks, Herman Vierendeels,Ternat,Belgium ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php
