Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » iText »

Re: [iText-questions] Adding borders to MultiColumnText

mister bean

2007-07-06

Replies:


If you're looking for a specific method/API, there isn't one that I know of
in MCT (I've just been looking at the code).

You will have to draw the lines manually (that is, using lower level
methods). Bruno has an example that points you in the right direction on p.
208 of the book.

---Mister Bean

>>>


iTEXT USER wrote:
>
> Hi,
> I have used MultiColumnText to add PdfPTables continoulsly as below.
> I need to have line borders for the columns. Is there any way to draw line
> borders between the columns of MultiColumnText.
> For e.g. We have setBorder(int border) method for PdfPCell. I need to have
> similar functionality.
> Expecting your suggestions ASAP.
>
> -----------------------------------------------------------------------------
> package com.itext.pdf.client;
>
> import java.io.FileNotFoundException;
> import java.io.FileOutputStream;
>
> import com.lowagie.text.Document;
> import com.lowagie.text.DocumentException;
> import com.lowagie.text.Paragraph;
> import com.lowagie.text.pdf.MultiColumnText;
> import com.lowagie.text.pdf.PdfPCell;
> import com.lowagie.text.pdf.PdfPTable;
> import com.lowagie.text.pdf.PdfWriter;
>
> public class Test {
>
>  /**
>   * @param args
>   */
>  public static void main(String[] args) {
>    //Creating new document
>    Document doc = new Document();
>    try {
>      PdfWriter.getInstance(doc, new FileOutputStream(
>          "files/multicolumntext.pdf"));
>      //Open it
>      doc.open();
>      
>      //New Multicolumn text
>      MultiColumnText mct = new MultiColumnText();
>      mct.addRegularColumns(doc.left(), doc.right(), 0.1f, 4);
>      //Adding PdfPTables
>      for (int i = 0; i < 200; i++) {
>        PdfPTable childTable = new PdfPTable(1);
>        Paragraph paragraph = new Paragraph("TEST PARAGRAPH "+i);
>        PdfPCell pCell = new PdfPCell(paragraph);
>        pCell.setBorder(0);
>        childTable.addCell(pCell);
>        
>        
>        mct.addElement(childTable);
>      }
>      //Adding MultiColumnText to document
>      doc.add(mct);
>      //Finally closing document
>      doc.close();
>    } catch (FileNotFoundException e) {      
>      e.printStackTrace();
>    } catch (DocumentException e) {      
>      e.printStackTrace();
>    }
>
>  }
>
> }
>
> Regards,
> iTEXT USER
>

--
Sent from the iText - General mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
iText-questions mailing list
iText-questions@(protected)
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/
©2008 junlu.com - Jax Systems, LLC, U.S.A.