setPading()
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of Kevin Buhr
> Sent: Friday, September 08, 2006 5:40 PM
> To: [email protected]
> Subject: [iText-questions] trouble with making the spacing
> smaller betweencells on label
>
>
> I am having trouble making the spacing smaller between cells
> on a label.
> Any ideas would be greatly appreciated! :)
>
>
> The following prints the label ok:
>
> private PdfPTable createPage( Image[] image, Phrase[] partNo,
> Phrase[] desc, Phrase inHousePartNo[])
> {
> float[] widths = {.333f, .333f, .333f};
>
> PdfPTable table = new PdfPTable( widths );
>
> table.setWidthPercentage( 100 );
>
>
>
> for ( int i=0; i<image.length; i++ )
> {
> PdfPTable t = new PdfPTable( 1 );
>
> PdfPCell cell = new PdfPCell( image[i] );
> cell.setHorizontalAlignment(
> com.lowagie.text.Element.ALIGN_LEFT );
> cell.setVerticalAlignment(
> com.lowagie.text.Element.ALIGN_BOTTOM );
> cell.setBorder( Rectangle.NO_BORDER );
> //cell.setFixedHeight( 48 );
> cell.setFixedHeight( 36 );
> //cell.setFixedHeight( 24 );
> t.addCell( cell );
>
> cell = new PdfPCell( partNo[i] );
> cell.setHorizontalAlignment(
> com.lowagie.text.Element.ALIGN_LEFT );
> cell.setVerticalAlignment(
> com.lowagie.text.Element.ALIGN_TOP );
> cell.setBorder( Rectangle.NO_BORDER );
> //cell.setFixedHeight( 16 );
> //cell.setFixedHeight( 12 );
>
> cell.setFixedHeight( 10 );
> //cell.setFixedHeight( 8 );
>
> t.addCell( cell );
>
>
> cell = new PdfPCell( desc[i] );
> cell.setHorizontalAlignment(
> com.lowagie.text.Element.ALIGN_LEFT );
> cell.setVerticalAlignment(
> com.lowagie.text.Element.ALIGN_TOP );
> cell.setBorder( Rectangle.NO_BORDER );
> //cell.setFixedHeight( 12 );
> //cell.setFixedHeight( 12 );
> cell.setFixedHeight( 10 );
> //cell.setFixedHeight( 8 );
>
> t.addCell( cell );
>
> cell = new PdfPCell( inHousePartNo[i] );
> cell.setHorizontalAlignment(
> com.lowagie.text.Element.ALIGN_LEFT );
> cell.setVerticalAlignment(
> com.lowagie.text.Element.ALIGN_TOP );
> cell.setBorder( Rectangle.NO_BORDER );
> //cell.setFixedHeight( 12 );
> cell.setFixedHeight( 10 );
> //cell.setFixedHeight( 8 );
>
> t.addCell( cell );
>
>
> //t.setSpacingAfter( 11 );
> //t.setSpacingAfter( 3 );
>
> t.setSpacingAfter( 9 );
> //t.setSpacingAfter( 15 );
>
>
> PdfPCell main = new PdfPCell( t );
> main.setBorder( Rectangle.NO_BORDER );
>
> if ( i%3 == 1 )
> main.setPaddingLeft( 6f );
> else if ( i%3 == 2)
> main.setPaddingLeft( 20f );
>
> table.addCell( main );
>
> if ( ( image.length < DIM ) && ( i ==
> image.length-1 ) )
> {
> if ( i%3<1 )
> {
> t = new PdfPTable( 1 );
>
> cell = new PdfPCell();
> cell.setBorder( Rectangle.NO_BORDER );
> t.addCell( cell );
>
> main = new PdfPCell( t );
> main.setBorder( Rectangle.NO_BORDER );
> table.addCell( main );
> }
> if ( i%3<2 )
> {
> t = new PdfPTable( 1 );
>
> cell = new PdfPCell();
> cell.setBorder( Rectangle.NO_BORDER );
> t.addCell( cell );
>
> main = new PdfPCell( t );
> main.setBorder( Rectangle.NO_BORDER );
> table.addCell( main );
> }
> }
> }
>
> return table;
> }
>
> (Embedded image moved to file: pic25340.jpg)
>
> When I try and decrease the spacing bewteen the cells some
> data does not
> display:
>
> (Embedded image moved to file: pic25432.jpg)
>
> private PdfPTable createPage( Image[] image, Phrase[] partNo,
> Phrase[] desc, Phrase inHousePartNo[])
> {
> float[] widths = {.333f, .333f, .333f};
> PdfPTable table = new PdfPTable( widths );
>
> table.setWidthPercentage( 100 );
>
>
>
> for ( int i=0; i<image.length; i++ )
> {
> PdfPTable t = new PdfPTable( 1 );
>
> PdfPCell cell = new PdfPCell( image[i] );
> cell.setHorizontalAlignment(
> com.lowagie.text.Element.ALIGN_LEFT );
> cell.setVerticalAlignment(
> com.lowagie.text.Element.ALIGN_BOTTOM );
> cell.setBorder( Rectangle.NO_BORDER );
> //cell.setFixedHeight( 48 );
> cell.setFixedHeight( 36 );
> //cell.setFixedHeight( 24 );
> t.addCell( cell );
>
> cell = new PdfPCell( partNo[i] );
> cell.setHorizontalAlignment(
> com.lowagie.text.Element.ALIGN_LEFT );
> cell.setVerticalAlignment(
> com.lowagie.text.Element.ALIGN_TOP );
> cell.setBorder( Rectangle.NO_BORDER );
> //cell.setFixedHeight( 16 );
> //cell.setFixedHeight( 12 );
>
> //cell.setFixedHeight( 10 );
> cell.setFixedHeight( 8 );
>
> t.addCell( cell );
>
>
> cell = new PdfPCell( desc[i] );
> cell.setHorizontalAlignment(
> com.lowagie.text.Element.ALIGN_LEFT );
> cell.setVerticalAlignment(
> com.lowagie.text.Element.ALIGN_TOP );
> cell.setBorder( Rectangle.NO_BORDER );
> //cell.setFixedHeight( 12 );
> //cell.setFixedHeight( 12 );
> //cell.setFixedHeight( 10 );
> cell.setFixedHeight( 8 );
>
> t.addCell( cell );
>
> cell = new PdfPCell( inHousePartNo[i] );
> cell.setHorizontalAlignment(
> com.lowagie.text.Element.ALIGN_LEFT );
> cell.setVerticalAlignment(
> com.lowagie.text.Element.ALIGN_TOP );
> cell.setBorder( Rectangle.NO_BORDER );
> //cell.setFixedHeight( 12 );
> //cell.setFixedHeight( 10 );
> cell.setFixedHeight( 8 );
>
> t.addCell( cell );
>
>
> //t.setSpacingAfter( 11 );
> //t.setSpacingAfter( 3 );
> //t.setSpacingAfter( 9 );
> t.setSpacingAfter( 15 );
>
>
> PdfPCell main = new PdfPCell( t );
> main.setBorder( Rectangle.NO_BORDER );
>
> if ( i%3 == 1 )
> main.setPaddingLeft( 6f );
> else if ( i%3 == 2)
> main.setPaddingLeft( 20f );
>
> table.addCell( main );
>
> if ( ( image.length < DIM ) && ( i ==
> image.length-1 ) )
> {
> if ( i%3<1 )
> {
> t = new PdfPTable( 1 );
>
> cell = new PdfPCell();
> cell.setBorder( Rectangle.NO_BORDER );
> t.addCell( cell );
>
> main = new PdfPCell( t );
> main.setBorder( Rectangle.NO_BORDER );
> table.addCell( main );
> }
> if ( i%3<2 )
> {
> t = new PdfPTable( 1 );
>
> cell = new PdfPCell();
> cell.setBorder( Rectangle.NO_BORDER );
> t.addCell( cell );
>
> main = new PdfPCell( t );
> main.setBorder( Rectangle.NO_BORDER );
> table.addCell( main );
> }
> }
> }
>
> return table;
> }
>
>
>
>
>
> the following calls the above method
>
>
> public void buildSingleLabel()
> {
> com.lowagie.text.Document pdf = getPdfDocument();
>
> Image[] image = null;
> Phrase[] partNo = null;
> Phrase[] desc = null;
> Phrase[] inHousePartNo = null;
>
> // initialize arrays
> image = new Image[1];
> partNo = new Phrase[1];
> desc = new Phrase[1];
> inHousePartNo = new Phrase[1];
>
> try
> {
> // create new page
> pdf.newPage();
>
> // Set Partnumber and barcode
> image[0] = createBarcode( _inHousePn );
> //inHousePartNo[0] = createPhrase( _inHousePn, 8,
> Color.black );
> inHousePartNo[0] = createPhrase( _inHousePn,
> 6, Color.black
> );
>
> String value = _custPn;
> if ( value.equals( "" ) )
> value = _inHousePn;
>
> //partNo[i%DIM] = createPhrase( stripEquals(
> value ), 12,
> Color.red );
> //partNo[0] = createPhrase( stripEquals( value ), 8,
> Color.red );
> partNo[0] = createPhrase( stripEquals( value ),
> 6, Color.red
> );
>
> // Set description
> value = _custDesc;
> if (value.trim().equals( "" ))
> value = _shortDesc;
>
> //desc[0] = createPhrase( value, 8, Color.black );
> desc[0] = createPhrase( value, 6, Color.black );
>
> PdfPTable page = createPage( image, partNo, desc,
> inHousePartNo);
> pdf.add( page );
>
> _perc = 100;
> }
> catch( DocumentException de )
> {
> de.printStackTrace();
> }
>
> // Close the document after building
> pdf.close();
> }
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> _ _ _ _ _ _ _
>
> This e-mail message, including attachments, may contain
> confidential, proprietary, or export controlled information.
> Any unauthorized disclosure, distribution, or other use is
> prohibited, unless expressly authorized. If you receive this
> e-mail in error, please notify the sender, and delete all
> copies of the original message from your systems.
>
Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter
informação confidencial ou legalmente protegida. A incorrecta transmissão desta
mensagem não significa a perca de confidencialidade. Se esta mensagem for
recebida por engano, por favor envie-a de volta para o remetente e apague-a do
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de
usar, revelar ou distribuir qualquer parte desta mensagem.
Disclaimer:
This message is destined exclusively to the intended receiver. It may contain
confidential or legally protected information. The incorrect transmission of
this message does not mean the loss of its confidentiality. If this message is
received by mistake, please send it back to the sender and delete it from your
system immediately. It is forbidden to any person who is not the intended
receiver to use, distribute or copy any part of this message.
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions