I would like to fire an event to iterate through the rows and columns of 
pdfptable  to get celltext as well as coordinates.

This satisfies 2 of my needs:

1.       With x,y coordinates I can write lines and dividers back to report 
based on key words

2.       I create Excel and HTML files from table data

The examples I find are far more complex than I need to accomplish my simple 
need.
Here is code I have so far.  It is written in VB.NET but I can convert C# to 
VB.NET


' Using Itextsharp not itext so some methods may differ

Public Sub CreatePDF()
    Dim doc As New Document
    PdfWriter.GetInstance(doc, New FileStream("myfile.pdf", FileMode.Create))
    doc.Open()
    Dim my_pdf_tbl As PdfPTable
    my_pdf_tbl = New PdfPTable(3)   ' contains 3 rows
    my_pdf_tbl.WidthPercentage = 100.0F
    my_pdf_tbl.DefaultCell.Border = PdfCell.NO_BORDER
    my_pdf_tbl.AddCell("Date")
    my_pdf_tbl.AddCell("Sales")
    my_pdf_tbl.AddCell("Guests")
    my_pdf_tbl.HeaderRows = True    'End of table header
    my_pdf_tbl.AddCell("0/21/2009")
    my_pdf_tbl.AddCell("2345.09")
    my_pdf_tbl.AddCell("17")
    my_pdf_tbl.AddCell("0/21/2009")
    my_pdf_tbl.AddCell("2345.09")
    my_pdf_tbl.AddCell("17")
    doc.Add(my_pdf_tbl)
    Dim myevent As New PdfPTableEvents
    my_pdf_tbl.setTableEvent(myevent)
    ' add the table with document add
    doc.Add(my_pdf_tbl)
     ' add the table at an absolute position
    my_pdf_tbl.WriteSelectedRows(0, -1, 100, 600, PdfWriter.getdirectcontent
    doc.Close()
End Sub

Public Class PdfPTableEvents
    Implements PdfPTableEvent
    '
    Public Sub tableLayout(ByVal table As PdfPTable, ByVal width()() As Double, 
ByVal height()() As Double)
        Dim sOutputTemplate As String = " Text is {0} : x-pos is {1} : y-pos is 
{2} : cell height is {3} : cell width is {4}"
        For i As Integer = 0 To 3
            For j As Integer = 0 To 3
                ' I will write Values to Excel file here
               debug.Writeline(string.Format(sOutputTemplate, text, x, y, 
width, height)
            Next j
        Next i
    End Sub

End Class

SECOND QUESTION

I am trying to persuade upper management that they will not lose features if we 
migrate from Excel to  PDF instead
In one report there are 50  columns of  totals for each  of their stores which 
they can read by simply moving horizontal scroll bar to the last column in 
Excel.
Can I accomplish the same with Itext/sharp?

Thanks in advance,
Rodney Williams/Programmer

------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
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