hi,
One more thing I found out in this respect is that
if you put the cell event on the container cell (the
cell with green cell background) the cell event is
rendered and lines extend on the next pages, but
anything inside these cell do not.
thanks,
amit.
--- Amit Gijare <[EMAIL PROTECTED]> wrote:
> Hi,
>
> below is the test code, you could run this code,
> the yellow background cells are the one where cell
> event is fired for drawing the lines but they do not
> extend to other page while the cell in which they
> are extend, green background..
>
> thanks,
> amit.
>
> public class TestClass
> {
> private static int _signLength = 30;
> public static void main (String args[])
> {
> createDocumentation();
> }
> private static void createDocumentation( )
> {
> final Document document = new Document(
> PageSize.A6 );
> /// A4 or other sizes
> try
> {
> final PdfWriter writer =
> PdfWriter.getInstance( document, new
> FileOutputStream( "Test.pdf ") );
> 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 );
> Map tree= prepareNodeData();
> table.setHorizontalAlignment(
> Element.ALIGN_LEFT );
> final PdfPTable table1 =
> generatePDFDocument( writer, tree, document );
> table.addCell( table1 );
> document.add( table );
> table.setSplitRows( true );
> document.newPage();
> writer.setPageEmpty( false );
> document.newPage();
> }
> catch ( Exception e )
> {
> e.printStackTrace( );
> }
> document.close();
> }
> private static PdfPTable generatePDFDocument(
> final PdfWriter writer, final Map tree, Document
> document ) throws Exception
> {
> return getPDFStructure( writer, tree, "0",
> 350, 0, document, 0 );
> }
> private static PdfPTable getPDFStructure( final
> PdfWriter writer, final Map tree, final String
> nodeID,int descLength,
> final int depth, Document
> document, int childCount ) throws IOException,
> DocumentException
> {
> int signLength = 30;
> final Node node = (Node)tree.get( 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 static PdfPTable getIconTable( final
> Node node, final PdfWriter writer, final Map 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 = new PdfPCell( new
> Phrase ("--"));// cell with line
> final PdfPCell cellIcon = new PdfPCell( new
> Phrase ("|X|"));// cell with ObjectIcon;
> final PdfPCell cellText = new PdfPCell( new
> Phrase ("test " + node.getId() ));// cell with
> ObjectText;
> final PdfPCell cellEndIcon = new PdfPCell(
> new Phrase ("-E-"));// 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.getChilds().isEmpty() )
> {
> 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 static 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(
> new Phrase ("|_"));
> if ( node.draw() )
> {
>
=== message truncated ===
__________________________________________________
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