writeSelectedRows + TableLayout + System.ArgumentOutOfRangeException: Index was out of range.

Arjundiwan <[email protected]>
Newsgroups gmane.comp.java.lib.itext.general
Message-ID <[email protected]>
I have tried whatever I could in last two days, but unfortunately I'm still
stuck with this, something silly I'm doing for sure because I love and trust
iText to the core. So here is my problem explained via a simple code, and
hope someone has an answer to it:


 Public Class TableBackground
        Implements iTextSharp.text.pdf.IPdfPTableEvent

        Sub TableLayout(table As iTextSharp.text.pdf.PdfPTable, widths()()
As Single, heights() As Single, _
                        headerRows As Integer, rowStart As Integer,
canvases() As iTextSharp.text.pdf.PdfContentByte) _
                    Implements IPdfPTableEvent.TableLayout

        End Sub
 End Class
       
--Some place else in the code file----
            Dim htmltable As New PdfPTable(5)
            htmltable.TableEvent = New TableBackground()
            htmltable.TotalWidth = 100
            htmltable.AddCell("1A")
            htmltable.AddCell("1B")
            htmltable.AddCell("1C")
            htmltable.AddCell("1D")
            htmltable.AddCell("1E")
            htmltable.AddCell("2A")
            htmltable.AddCell("2B")
            htmltable.AddCell("2C")
            htmltable.AddCell("2D")
            htmltable.AddCell("2E")
            htmltable.AddCell("3A")
            htmltable.AddCell("3B")
            htmltable.AddCell("3C")
            htmltable.AddCell("3D")
            htmltable.AddCell("3E")
            htmltable.HeaderRows = 1
            'Print first Row of htmltable
            htmltable.WriteSelectedRows(0, 5, 0, 1, 40, 700, pdfCanvas)

            document.NewPage()

            'Print Last 2 Rows of htmltable
            htmltable.WriteSelectedRows(0, 5, 1, 2, 40, 700, pdfCanvas)

            document.close
--Some place else in the code file----

The first *WriteSelectedRows* executes well and writes one row to the pdf
page. But, at the second *WriteSelectedRows* where I'm trying to print the
last two rows on the next page, my code fails with the below error code:
/System.ArgumentOutOfRangeException: Index was out of range. Must be
non-negative and less than the size of the collection./

The closest I could reach to this error is that it has something to do with
the TableEvent. If i comment out /htmltable.TableEvent = New
TableBackground()/ in the above code, it starts running as expected.

I'm using /htmltable.TableEvent = New TableBackground()/ for alternate
coloring while printing htmltable rows. For simplicity I have removed any
code in the TableLayout method, it still throws error.






--
View this message in context: http://itext-general.2136553.n4.nabble.com/writeSelectedRows-TableLayout-System-ArgumentOutOfRangeException-Index-was-out-of-range-tp4660415.html
Sent from the iText - General mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.