When I use setLeading(), setVerticalAlignment() is not effective for cell,
in this case text is always bottom aligned no matter what type of alignment
you set.

cell.setLeading(30)     ;
cell.setVerticalAlignment(Cell.ALIGN_MIDDLE);




                                                                           
             Bruno                                                         
             <[EMAIL PROTECTED]                                             
             m>                                                         To 
                                       [EMAIL PROTECTED]            
             01/10/2004 05:08                                           cc 
             AM                        [EMAIL PROTECTED] 
                                       et                                  
                                                                   Subject 
                                       Re: Why is my table so compact?     
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




Quoting [EMAIL PROTECTED]:

>
>
>
>
> I am writing a table to pdf doc, but it's always compacted. How to
achieve
> some space above and below to text ( How to increase cell height?).

What if you change the leading of the Cell?

> My code follows:
>
> public void doGet(HttpServletRequest req, HttpServletResponse resp)
>             throws ServletException, IOException {
>
>       try{
>
>             ByteArrayOutputStream ba = new ByteArrayOutputStream();
>           Document document = new Document(PageSize.A4, 10, 10, 10, 10);
>             PdfWriter.getInstance(document, ba);
>
>             document.open();
>
>             Table datatable = new Table(2);
>         datatable.setBorder(Rectangle.NO_BORDER);
>         int headerwidths[] = { 50, 50};
>         datatable.setWidths(headerwidths);
>         datatable.setWidth(100);
>
>             Table earnings = new Table(4);
>             earnings.setPadding(2);
>       earnings.setSpacing(2);
>             int earningswidths[] = {40,10,25,25};
>         earnings.setWidths(earningswidths);
>         earnings.setWidth(100);
>             earnings.setAlignment(Table.ALIGN_MIDDLE);
>
>
>             earnings.addCell(secHeading("Earnings"));
>             earnings.addCell(secHeading("Hours"));
>             earnings.addCell(secHeading("Amount"));
>             earnings.addCell(secHeading("YTD"));
>
>             earnings.addCell(secData("Pay 1"));
>             earnings.addCell(secData(""));
>             earnings.addCell(secData("$12,180.00"));
>             earnings.addCell(secData("$118,200.00"));
>
>             earnings.addCell(secData("Pay 2"));
>             earnings.addCell(secData(""));
>             earnings.addCell(secData("$5.92"));
>             earnings.addCell(secData("$59.20"));
>
>             datatable.insertTable(earnings);
>
>             document.add(datatable);
>             document.close();
>
>                   resp.setContentType("application/pdf");
>                   resp.setContentLength(ba.size());
>                   ServletOutputStream out = resp.getOutputStream();
>                   ba.writeTo(out);
>                   ba.close();
>
>                   out.flush();
>                   out.close();
>                   System.out.println("Finished.");
>       }catch(Exception e){}
>
>       }
>
>       public Cell secHeading(String data) throws BadElementException
>       {
>
>             Font font = FontFactory.getFont(FontFactory.HELVETICA, 9,
> Font.BOLD,new Color(255,255,255));
>
>             Cell cell = new Cell(new Phrase(data, font));
>             cell.setVerticalAlignment(Cell.ALIGN_MIDDLE);
>             cell.setBackgroundColor(new Color(52,102,153));
>
>             return cell;
>       }
>       public Cell secFooter(String data) throws BadElementException
>       {
>             Cell cell = new Cell(new Phrase(data,
> FontFactory.getFont(FontFactory.HELVETICA, 9, Font.BOLD)));
>             cell.setVerticalAlignment(Cell.ALIGN_MIDDLE);
>             cell.setBackgroundColor(new Color(204,204,204));
>
>             return cell;
>       }
>       public Cell secData(String data) throws BadElementException
>       {
>             Cell cell = new Cell(new Phrase(data,
> FontFactory.getFont(FontFactory.HELVETICA, 9, Font.NORMAL)));
>             cell.setVerticalAlignment(Cell.ALIGN_MIDDLE);
>
>             return cell;
>       }




-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software.
Perforce is the Fast Software Configuration Management System offering
advanced branching capabilities and atomic changes on 50+ platforms.
Free Eval! http://www.perforce.com/perforce/loadprog.html
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to