I don't want to see your production code. I want a simple example that I can run here (with main()).
> -----Original Message----- > From: Amit Gijare [mailto:[EMAIL PROTECTED] > Sent: Wednesday, April 27, 2005 12:27 PM > To: Paulo Soares; [email protected] > Subject: RE: [iText-questions] Cell events and page breaks, > > I have this following example, if you try to go > over pages with depth of childs (in horizontal as well > vertical direction) increasing, then at page breaks > outer table refuse to extend even thought the cell > extends to next page the cellevent does not.. > > code sample below.... > > > private void createDocumentation ( final > HttpServletResponse response ,final > HttpServletRequest request ) > { > final Document document = generateDocument(); > /// A4 or other sizes > try > { > final PdfWriter writer = > PdfWriter.getInstance(document, > response.getOutputStream() ); > document.open(); > final PdfPTable table = new PdfPTable(1); > table.getDefaultCell().setPadding(0); > table.getDefaultCell().setBorder(0); > table.setSplitRows( true ); > table.setSplitLate( false ); > table.setWidthPercentage(98); > > table.setHorizontalAlignment(Element.ALIGN_LEFT); > final PdfPTable table1 = > generatePDFDocument(writer, tree, document); > table.addCell( table1 ); > document.add(table); > table.setSplitRows(true); > > response.setContentType("application/pdf"); > document.newPage(); > writer.setPageEmpty(false); > document.newPage(); > } > catch ( Exception e ) > { > ExceptionUtil.printStackTrace(e); > } > document.close(); > } > > private PdfPTable generatePDFDocument(final > PdfWriter writer, final ObjectTree tree, Document > document) throws Exception > { > String nodeID = tree.getRootNodeID(); > return getPDFStructure(writer, tree, nodeID, > 350, 0, document, 0 ); > } > > private PdfPTable getPDFStructure(final PdfWriter > writer,final ObjectTree tree, final String nodeID, > int descLength, > final int depth, Document document, int childCount ) > throws IOException, DocumentException > { > int signLength = 30; > final Node node = tree.getNode(nodeID); > if( descLength < 0) > { > descLength =100; > } > > final float width[]= { signLength, descLength > } ; > final PdfPTable table = getPDFTable( width ); > table.getDefaultCell().setNoWrap( false ); > table.setTotalWidth( signLength+ descLength ); > table.setLockedWidth(true); > > table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); > > table.setHorizontalAlignment(Element.ALIGN_LEFT); > PdfPTable tableSign = getSignTable( node); > PdfPCell cell = new PdfPCell(tableSign ); > cell.setBackgroundColor( Color.GREEN ); > table.addCell(cell); > PdfPTable innerTable = getIconTable( node, > writer, tree, descLength - signLength, depth, > document, childCount ); > PdfPCell cell1 = new PdfPCell(innerTable ); > table.addCell( cell1); > return table; > } > > private static PdfPTable getPDFTable( final > float[] width ) > { > final PdfPTable table = new PdfPTable( width > ); > table.getDefaultCell().setPadding(0); > table.getDefaultCell().setBorder(0); > > table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); > table.setExtendLastRow(true); > table.setSplitRows( true ); > table.setSplitLate( false ); > return table; > } > > > private PdfPTable getIconTable( final Node node, > final PdfWriter writer, final ObjectTree tree, > final int > descLength, int depth, Document document, int > childCount ) throws IOException, DocumentException > { > final float[] outerWidth= { 10 + 22 + 100 + 16 > } ; > final PdfPTable outerTable = getPDFTable( > outerWidth ); > > outerTable.setHorizontalAlignment(Element.ALIGN_LEFT); > > final float[] width= { 10, 22, 100, 16 } ; > final PdfPTable table = getPDFTable( width ); > > > table.setSplitRows( false ); > table.setSplitLate( true ); > > > table.setHorizontalAlignment(Element.ALIGN_LEFT); > table.setTotalWidth( 10 + 22 + 100 + 16 ); > table.setLockedWidth( true ); > > final PdfPCell cellLine // cell with line > final PdfPCell cellIcon = // cell with > ObjectIcon; > final PdfPCell cellText = // cell with Object > Text; > final PdfPCell cellEndIcon = // cell with end > icon ; > > table.addCell( cellLine ); > table.addCell(cellIcon ); > table.addCell( cellText ); > table.addCell( cellEndIcon ); > PdfPCell cell1 = new PdfPCell(table); > outerTable.addCell( cell1 ); > > if( node.getChildCount() > 0 ) > { > depth++; > final Iterator it = > node.getChilds().iterator(); > while(it.hasNext()) > { > final String childNodeID = > (String)it.next(); > //System.out.println( " creating for > nodeID " + childNodeID ); > PdfPCell cell = new > PdfPCell(getPDFStructure(writer, tree, childNodeID, > descLength - signLength, depth, document, childCount) > ); > outerTable.addCell( cell ); > childCount++; > } > } > return outerTable; > } > > > private PdfPTable getSignTable( final Node node ) > throws IOException, BadElementException > { > final float width[]= {10,20} ; > final PdfPTable table = new PdfPTable( width > ); > table.getDefaultCell().setBackgroundColor( > Color.RED ); > > table.getDefaultCell().setBorder(Rectangle.NO_BORDER); > table.setSplitRows( false ); > table.setSplitLate( true ); > table.setExtendLastRow( true ); > PdfEvents event = new PdfEvents(); > table.setTableEvent(event); > table.setTotalWidth( signLength); > table.setLockedWidth(true); > final Image imgMinusStr = Image.getInstance ( > new URL( Constants.PDF_NODE_SIGN) )); > final PdfPCell cellImgMinus = new PdfPCell( > imgMinusStr ); > > if ( Boolean.valueOf( > (String)node.getNodeProperty("DRAW") ).booleanValue()) > { > final PdfEvents events = new PdfEvents(); > cellImgMinus.setCellEvent( events ); > cellImgMinus.setBackgroundColor( > Color.YELLOW ); > cellImgMinus.setNoWrap(false); > > } > PdfPCell eCell = getImageCell(); > eCell.setBorder(1); > eCell.setBackgroundColor( Color.CYAN ); > table.addCell( eCell ); > table.addCell( cellImgMinus ); > return table; > } > > class PdfEvents implements > PdfPCellEvent,PdfPTableEvent > { > public void cellLayout(final PdfPCell cell, > final Rectangle position,final PdfContentByte[] > canvases) > { > final PdfContentByte cb = > canvases[PdfPTable.TEXTCANVAS]; > cb.moveTo(position.left() + ( > position.right() - position.left())/2 , > position.bottom()); > cb.lineTo(position.left() + ( > position.right() - position.left())/2 , > position.top() ); > cb.stroke(); > } > > public void tableLayout( PdfPTable table, > float[][] width, float[] height, int headerRows, int > rowStart, PdfContentByte[] canvases ) > { > float widths[] = width[0]; > float x1 = widths[0]; > float x2 = widths[widths.length - 1]; > float y1 = height[0]; > float y2 = height[height.length - 1]; > PdfContentByte canvas = > canvases[PdfPTable.LINECANVAS]; > canvas.setRGBColorStroke(0x00, 0x00, > 0xFF); > canvas.rectangle(x1, y1, x2 - x1, y2 - > y1); > canvas.stroke(); > canvas.resetRGBColorStroke(); > } > } > > > > > > > --- Paulo Soares <[EMAIL PROTECTED]> wrote: > > The cell event is from the time when cells didn't > > split, it's possible > > that there are some inconsistencies. Post a small > > example with the > > problem. > > > > > -----Original Message----- > > > From: [EMAIL PROTECTED] > > > > > [mailto:[EMAIL PROTECTED] > > On > > > Behalf Of Amit Gijare > > > Sent: Wednesday, April 27, 2005 10:18 AM > > > To: [email protected] > > > Subject: [iText-questions] Cell events and page > > breaks, > > > > > > hi, > > > > > > are cell events influenced by page breaks, I > > have > > > an cell event which draws line in a cell, works > > fine > > > if its a single page, but not when it extends over > > > multiple pages. I tried changing the page layout > > from > > > A4 to A2 and it works fine, or is that splitting > > of > > > rows influences cell events. > > > > > > thanks, > > > amit. > > > > > > __________________________________________________ > > > Do You Yahoo!? > > > Tired of spam? Yahoo! Mail has the best spam > > protection around > > > http://mail.yahoo.com > > > > > > > > > > > > ------------------------------------------------------- > > > SF.Net email is sponsored by: Tell us your > > software development plans! > > > Take this survey and enter to win a one-year sub > > to SourceForge.net > > > Plus IDC's 2005 look-ahead and a copy of this > > survey > > > Click here to start! > > http://www.idcswdc.com/cgi-bin/survey?id=105hix > > > _______________________________________________ > > > iText-questions mailing list > > > [email protected] > > > > > > https://lists.sourceforge.net/lists/listinfo/itext-questions > > > > > > > > > > ------------------------------------------------------- > > SF.Net email is sponsored by: Tell us your software > > development plans! > > Take this survey and enter to win a one-year sub to > > SourceForge.net > > Plus IDC's 2005 look-ahead and a copy of this survey > > Click here to start! > > http://www.idcswdc.com/cgi-bin/survey?id5hix > > _______________________________________________ > > iText-questions mailing list > > [email protected] > > > https://lists.sourceforge.net/lists/listinfo/itext-questions > > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > ------------------------------------------------------- SF.Net email is sponsored by: Tell us your software development plans! Take this survey and enter to win a one-year sub to SourceForge.net Plus IDC's 2005 look-ahead and a copy of this survey Click here to start! http://www.idcswdc.com/cgi-bin/survey?id5hix _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions
