Hi everyone,

I know this question has been asked before, but I still can't figure
out what the answer is. I am trying to write the text within a
PdfPCell vertically, instead of horizontally.

I searched for this topic and found the following answer from Paulo:

"set the cell with a fixed height and use a PdfPCellEvent to paint the
text or whatever you want with the PdfContentByte provided."

So that's what I tried to do (see the code below). The problem is that
in the cellLayout method from the MyCellEvent, I still don't know how
to tell the "existing" text from the cell to display vertically.

I would really appreciate any help with this matter.

Thanks for your time,

Philip

class MyCellEvent implements PdfPCellEvent
{
  public void cellLayout(PdfPCell pdfPCell, Rectangle rectangle, 
      PdfContentByte[] pdfContentBytes)
  {
    PdfContentByte cb = pdfContentBytes[PdfPTable.TEXTCANVAS];

    // here I need to tell the cell that the text should be displayed vertically
    // not horizontally, but I do not know how to do that.
    cb.beginText();

    Chunk chunk = (Chunk) pdfPCell.getPhrase().get(0);
    cb.setFontAndSize(chunk.font().getBaseFont(), chunk.font().size());

    // as you can see, I was able to write an additional text here (vertically)
    // but this is not what I want. I need to tell the text that is already in
    // the cell to be displayed vertically! How do I do that?
    cb.setTextMatrix(0, 1, -1, 0, rectangle.right(), rectangle.top());
    cb.showText("Text");

    cb.endText();
  }
}

// create table
PdfPTable table = new PdfPTable(4);

Font font = ReportUtils.GetFont(10, Font.NORMAL, Color.BLACK);
Chunk chunk = new Chunk(aCellString, font);

// create cell
PdfPCell cell = new PdfPCell(new Phrase(20, chunk));
cell.setFixedHeight(100);

// set cell event
MyCellEvent event = new MyCellEvent();
cell.setCellEvent(event);

// add cell to table
aTable.addCell(cell);


-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to