Hi,

Below is the corrected code.

There was no use of position variable and the border of other cells were not
set to NO_BORDER
earlier.


class DashExample implements PdfPCellEvent {

        public void cellLayout(PdfPCell cell, Rectangle position,
                        PdfContentByte[] canvases) {
                PdfContentByte cb = canvases[PdfPTable.LINECANVAS];
                cb.setLineCap(PdfContentByte.LINE_CAP_PROJECTING_SQUARE);
                cb.setLineDash(6, 0);
                cb.moveTo(position.getLeft(), position.getBottom());
                cb.lineTo(position.getRight(), position.getBottom());
                cb.stroke();
        }
}

public class PptGeneratorTest extends TestCase {

        public void testPdfTable() {
                Document document = new Document();

                try {

                        PdfWriter.getInstance(document, new FileOutputStream(
                                        "MyFirstTable.pdf"));

                        // step 3: we open the document
                        document.open();

                        PdfPTable table = new PdfPTable(3);

                        DashExample example = new DashExample();
                        PdfPCell cell = new PdfPCell(new Paragraph("header with 
colspan 3"));
                        cell.setBorder(PdfPCell.NO_BORDER);
                        cell.setColspan(3);
                        cell.setCellEvent(example);
                        cell.setBottom(Rectangle.BOTTOM);
                        table.addCell(cell);

                        PdfPCell dell = new PdfPCell(new Paragraph("cell 
test1"));
                        dell.setBorder(PdfPCell.NO_BORDER);
                        table.addCell(dell);
                        PdfPCell zell = new PdfPCell(new Paragraph("cell 
test2"));
                        zell.setBorder(PdfPCell.NO_BORDER);
                        zell.setColspan(2);
                        table.addCell(zell);
                        document.add(table);
                } catch (DocumentException de) {
                        System.err.println(de.getMessage());
                } catch (IOException ioe) {
                        System.err.println(ioe.getMessage());
                }

                // step 5: we close the document
                document.close();
        }
-- 
View this message in context: 
http://www.nabble.com/Doubt-in-PdfPCellEvent-tp23796855p23797628.html
Sent from the iText - General mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to