We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problem while performing a save

Hi,

I am getting Invalid index in Rows indexer: -1 exception when i perform a save.

objPDF.Save("test.pdf", SaveType.OpenInAcrobat, Response)

i could not understand which index is this exception reffering. Please guide me!!

Hello Yvette,

Thanks for considering Aspose.

Please share the code snippet so that we can test the scenario at our end.

We apologize for your inconvenience.

Hi!!

This is a part of code which i am writing. I have about 5 tables added to the same section. I also have one more question. How can i insert a blank space in between the tables, while adding tables to the same section like section.paragraph.add(table)?

Dim objPDF As Pdf = New Pdf()

Dim section As Section = objPDF.Sections.Add()

Dim tableSupervisorPDRComments As Table = New Table(section)

tableSupervisorPDRComments.ColumnWidths = "70% 30%"

tableSupervisorPDRComments.ColumnAdjustment = ColumnAdjustmentType.AutoFitToContent

tableSupervisorPDRComments.Border = New BorderInfo(15, 0.5)

tableSupervisorPDRComments.DefaultCellBorder = New BorderInfo(15, 0.5)

Dim rowSupervisorText As Row = tableSupervisorPDRComments.Rows.Add()

rowSupervisorText.Cells.Add("abcd").BackgroundColor = New Color("gray")

If CurrentEmployeedata.UpdtTs.HasValue Then

rowSupervisorText.Cells.Add("Date: " + CurrentEmployeedata.UpdtTs.Value.ToString("dd-MMM-yyyy"))

End If

Dim rowSupervisorValue As Row = tableSupervisorPDRComments.Rows.Add()

rowSupervisorValue.Cells.Add(CurrentEmployeedata.comment).ColumnsSpan = 2

'check condition to display the PDR comments or not

If Not PersonnelId = loggedOnUserPersonnelId Then

Dim rowPDRText As Row = tableSupervisorPDRComments.Rows.Add()

rowPDRText.Cells.Add("Comments").BackgroundColor = New Color("gray")

If UpdtTs.HasValue Then

rowPDRText.Cells.Add("Date: " + UpdtTs.Value.ToString("dd-MMM-yyyy"))

End If

Dim rowPDRValue As Row = tableSupervisorPDRComments.Rows.Add()

rowPDRValue.Cells.Add(PdcComment).ColumnsSpan = 2

End If

section.Paragraphs.Add(tableSupervisorPDRComments)

'end supervisor and PDR comments

'start of footer

Dim footer As HeaderFooter = New HeaderFooter(section)

section.OddFooter = footer

section.EvenFooter = footer

Dim tableFooter As Table = New Table(section)

tableFooter.ColumnWidths = "50% 50%"

Dim rowFooter As Row = tableFooter.Rows.Add()

rowFooter.Cells.Add("Footer")

rowFooter.Cells.Add("abc)" & vbCrLf & "Page: $p of $P ").Alignment = AlignmentType.Right

footer.Paragraphs.Add(tableFooter)

'end of footer

objPDF.Save("test.pdf", SaveType.OpenInAcrobat, Response)

Hello Yvette,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for considering Aspose.

I've tested the scenario with Aspose.Pdf for .NET 4.1.1 and I'm unable to notice the problem. In your code snippet, I've noticed that you're using some customer variables holding some values. I'm not sure about actual values, so for the sake of execution, I've commented out these variables and tested the scenario. The resultant PDF might not be as per your actual environment, but still for your reference, I've attached it.

Regarding your second query, In order to specify the gap between two tables, you can simply add a Text paragraph with no value to the paragraphs collection of section object.

section.Paragraphs.Add(New Text(""))

In case it does not satisfy your requirements or you've any further query, please feel free to contact.