Ok, so here's a standalone program and the PDF I guess you were originally 
getting?

Looks like there is a big border on the left... but before I play, is this how 
your's looks?

package whatever.you.test;
 
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.FontFactory;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Phrase;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;
 
/**
 * This example was written by Bruno Lowagie. It is part of the book 'iText in
 * Action' by Manning Publications. 
 * ISBN: 1932394796
 * http://www.1t3xt.com/docs/book.php 
 * http://www.manning.com/lowagie/
 */
 
public class PdfPTableCellSpacing {
 
        /**
         * Generates a PDF file with a table.
         * 
         * @param args
         *            no arguments needed here
         * @throws FileNotFoundException 
         * @throws DocumentException 
         */
        public static void main(String[] args) throws FileNotFoundException, 
DocumentException {
                PdfPTable main = new PdfPTable(1);
        main.setTotalWidth(350f);
        main.setSpacingAfter(0);
        main.setSpacingBefore(0);
        main.getDefaultCell().setBorder(Rectangle.NO_BORDER);

        main.setLockedWidth(true);
        for(int i=0; i < 15; i++){
            Paragraph title = new Paragraph(new Phrase(new 
Chunk("titel"+i,FontFactory.getFont(BaseFont.TIMES_ROMAN))));
            Paragraph par = new Paragraph(new Phrase(new Chunk("cell "+i,
FontFactory.getFont(BaseFont.TIMES_ROMAN))));
            par.setSpacingAfter(-1.5f);
            PdfPCell cell = new PdfPCell();
            cell.addElement(title);
            cell.addElement(par);
            Paragraph par2 = new Paragraph(new Phrase(new Chunk("nextline"
,FontFactory.getFont(BaseFont.TIMES_ROMAN))));
            par2.setSpacingAfter(-1.2f);
            applyDefaultCellProps(cell);
            cell.addElement(par2);
            main.addCell(cell);
        }

        Document document = new Document(new Rectangle(350f,
main.getTotalHeight())); //!!
        File file = new File("C:\\Temp\\sizeTest.pdf");
        FileOutputStream fos = new FileOutputStream(file);
        PdfWriter writer = PdfWriter.getInstance(document, fos);
        document.setMargins(0f,0f,0f,0f);   //eerst, daarna doc openen
        document.open();

        document.add(main);
        document.close();
        writer.close();
 
    }
        
        private static void applyDefaultCellProps(PdfPCell cell){
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.enableBorderSide(Rectangle.LEFT);
        cell.enableBorderSide(Rectangle.RIGHT);
        cell.setPadding(5);
        cell.setPaddingTop(0);
        cell.setPaddingBottom(2);
        cell.setUseAscender(false);
        cell.setUseDescender(false);
    }
        
}

Matthew

-----Original Message-----
From: fhomasp [mailto:[email protected]]
Sent: 09 June 2010 11:42
To: [email protected]
Subject: Re: [iText-questions] PdfPTable padding and spacing



This is my new cell config: 

private void applyDefaultCellProps(PdfPCell cell){
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.enableBorderSide(Rectangle.LEFT);
        cell.enableBorderSide(Rectangle.RIGHT);
        cell.setPadding(5);
        cell.setPaddingTop(0);
        cell.setPaddingBottom(2);
        cell.setUseAscender(true);
        cell.setUseDescender(true);
    }

I also set useAscender/decender(true) to the tables default cell.  But still
the whole document is cut wrongly.
-- 
View this message in context: 
http://itext-general.2136553.n4.nabble.com/PdfPTable-padding-and-spacing-tp2248510p2248628.html
Sent from the iText - General mailing list archive at Nabble.com.

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
iText-questions mailing list
[email protected]
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/

Land Registry's House Price Index is now live. www.landregistry.gov.uk

If you have received this e-mail and it was not intended for you, please let us 
know, and then delete it. Please treat our communications in confidence, as you 
would expect us to treat yours. Land Registry checks all mail and attachments 
for known viruses, however, you are advised that you open any attachments at 
your own risk.



The original of this email was scanned for viruses by the Government Secure 
Intranet virus scanning service supplied by Cable&Wireless Worldwide in 
partnership with MessageLabs. (CCTM Certificate Number 2009/09/0052.) On 
leaving the GSi this email was certified virus free.
Communications via the GSi may be automatically logged, monitored and/or 
recorded for legal purposes.

Attachment: sizeTest.pdf
Description: sizeTest.pdf

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
iText-questions mailing list
[email protected]
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/

Reply via email to