Here's an example of a rotated table.

import java.io.*;

import com.lowagie.text.*;
import com.lowagie.text.pdf.*;

public class vertical_table {
    public static void main(String[] args) {
        Document document = new Document(PageSize.A4, 50, 50, 50, 50);
        try {
            PdfWriter writer = PdfWriter.getInstance(document, new
FileOutputStream("c:\\vertical_table.pdf"));
            document.open();
            PdfPTable table = new PdfPTable(4);
 
table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
            for (int k = 0; k < 24; ++k)
                table.addCell("" + k);
            table.setTotalWidth(300);
            PdfContentByte cb = writer.getDirectContent();
            cb.concatCTM(0, 1, -1, 0, 0, 0); // change the two last
parameters to position the table
            table.writeSelectedRows(0, -1, 0, 0, cb);
            document.close();
        }
        catch (Exception de) {
            de.printStackTrace();
        }
    }
}

Best Regards,
Paulo Soares

> -----Original Message-----
> From: Bruno [SMTP:[EMAIL PROTECTED]]
> Sent: Monday, July 01, 2002 11:06
> To:   monojit
> Cc:   [EMAIL PROTECTED]
> Subject:      Re: [iText-questions] how to draw a table vertically?
> 
> Quoting monojit <[EMAIL PROTECTED]>:
> 
> > Hi
> >     I tried doing that.But all i get is an empty page.I tried using
> various
> > coordinates.But still i get an empty page.When i add the ContentByte
> while
> > writing the table,the table shows up,but when i use a template instead,i
> > get an empty page.
> > Sorry to bother u.
> 
> Maybe Paulo has an idea about what is going wrong.
> I forward this to the mailing list.
> 
> Bruno
> 
> > ----- Original Message -----
> > From: "Bruno" <[EMAIL PROTECTED]>
> > To: "monojit" <[EMAIL PROTECTED]>
> > Cc: <[EMAIL PROTECTED]>
> > Sent: Monday, July 01, 2002 2:24 PM
> > Subject: Re: [iText-questions] how to draw a table vertically?
> > 
> > 
> > > Quoting monojit <[EMAIL PROTECTED]>:
> > >
> > > > Hi Bruno
> > > >     Here is the code I have written.But it doesnt generate any
> pages.
> > >
> > > I see you created the PdfTemplate, but I don't see you adding the
> > > Template to the PdfContentByte.
> > >
> > > >     In writeSelectedRows() method of PdfPTable i am trying to add
> the
> > rows
> > > > to a template instead of PdfContentByte> is this approach ok?
> > >
> > > Yes.
> > >
> > > >    PdfWriter writer=PdfWriter.getInstance(document, new
> > > > FileOutputStream("C:\\tmp\\generatedReports\\test.pdf"));
> > >
> > > >   document.open();
> > >
> > > >    PdfContentByte cb=writer.getDirectContent();
> > > >    PdfTemplate tem=cb.createTemplate(200,200);
> > >
> > > >    PdfPTable table=new PdfPTable(1);
> > > >    PdfPCell cell=new PdfPCell(new Phrase("cell1"));
> > > >    table.addCell(cell);
> > > >    table.setTotalWidth(90);
> > > >    table.writeSelectedRows(0,-1,100,400,tem);
> > >
> > > cb.addTemplate(tem, 1f, 0, 0, 1f, 0, 0);
> > >
> > > (adds it without rotating it)
> > >
> > > Bruno
> > >
> 


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to