I'm creating a servlet to produce a PDF with a header.  I'm using  the Table class to hold all the data for the Header.
  Short example of what I'm trying to do in the html world
    <table width="100%">
      <tr>
        <td width"250">
           <table>
             ....
          </table>
        </td>
        <td align="center">
          <table>
            ...
          </table>
        </td>
        <td align="right">
          <table>
            ...
          </table>
        </td>
      </tr>
    </table>

  The problem I'm having is that the table will not take up the whole horizontal space of the PDF Header.  It seems to leave space to the right of the table and will not expand to the right edge of the PDF table.  Is there any way I can prevent that from happening?



Here is code that is producing the header
public void onStartPage(PdfWriter writer, Document document) {
        Font headerFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD);
   
        try {
            Table table = new Table(3,1);
            table.setTableFitsPage(true);
            table.setBorder(0);
            table.setSpacing(0);
            table.setDefaultCellBorder(0);
            table.setWidth(113f);
            table.setPadding(0);
            int [] widths = {40,45,20};
            table.setWidths(widths);
            table.setAutoFillEmptyCells(true);
           
           
            Table tmpTable = new Table(1,2);
            tmpTable.setAutoFillEmptyCells(true);
            tmpTable.setBorder(0);
            tmpTable.setSpacing(0);
            tmpTable.setDefaultCellBorder(0);
            tmpTable.setPadding(0);
            tmpTable.setSpaceBetweenCells(0);


            //Print the Quote Number
            String quoteText = "Quote #: " + this.getQuoteNumber();
            if(this.getQuoteRevNumber() >  0)
                quoteText = quoteText + " Rev " + this.getQuoteRevNumber();
                       
            Cell cell = new Cell(new Paragraph(quoteText, headerFont));
            cell.setBorder(0);
            tmpTable.addCell(cell, new Point(0,0));
           
            // Printing date
            SimpleDateFormat formatter = new SimpleDateFormat ("MM'/'dd'/'yy");
            cell = new Cell(new Paragraph("     Date: " + formatter.format(new Date()), headerFont));
            cell.setBorder(0);
            cell.setNoWrap(true);
            tmpTable.addCell(cell, new Point(1,0));
           
           
            cell = new Cell(tmpTable);
            cell.setBorder(0);
            cell.setVerticalAlignment(Element.ALIGN_TOP);
            table.addCell(cell, new Point(0,0));
           
               
           ;  cell = new Cell(new Paragraph("Modification Services Specification Sheet", headerFont));
            cell.setBorder(0);
            cell.setNoWrap(true);
            cell.setVerticalAlignment(Element.ALIGN_TOP);
            table.addCell(cell, new Point(0,1));
           
           
            tmpTable = new Table(2,1);
            tmpTable.setBorder(0);
            tmpTable.setDefaultCellBorder(0);   
            tmpTable.setPadding(0);

           
            cell = new Cell(this.getCompanyLogo());
            cell.setBorder(0);
            cell.setNoWrap(true);
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            tmpTable.addCell(cell, new Point(0,0));
           
            cell = new Cell(this.getVenderLogo());
            cell.setNoWrap(true);
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            tmpTable.addCell(cell, new Point(1,0));
           
           
            cell = new Cell(tmpTable);
            cell.setVerticalAlignment(Element.ALIGN_TOP);
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cell.setBorder(0);
            cell.setNoWrap(true);
            table.addCell(cell, new Point(0,2));
            table.setOffset(0);
           
            document.add(table);
        } catch (BadElementException e1) {e1.printStackTrace();
        } catch (DocumentException e) {e.printStackTrace();
        }
    }


Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.

Reply via email to