Free Support Forum - aspose.com

Object refernce not set to instance

HI,
I am getting a atrange error when i try to add table and row to the Write in file mode.Please help
Object refernce not set to instance.
at Aspose.Pdf.Xml.ᒱ.ᒺ(Pdf Ә, ޸ ޫ)
at Aspose.Pdf.Pdf.Close()

at PDFdisplay.GenerateSumDetailsReportCoveragePDF(String reportID) in
C:\TeamProj\Working
Branch\ClientWebsites\iMedia_v3.root\iMedia_v3\WebSites\iMedia_v3\PDFdisplay.aspx.vb:line
4311
at PDFdisplay.Page_Load(Object sender, EventArgs e) in
C:\TeamProj\Working
Branch\ClientWebsites\iMedia_v3.root\iMedia_v3\WebSites\iMedia_v3\PDFdisplay.aspx.vb:line
8274
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Please find the code below :

Dim fs As FileStream = New FileStream("\ABC\Press\SingleSeg-d.pdf", FileMode.Create)



'Instantiate the Pdf instance and pass the file stream object to its constructor

Dim _pdf As Aspose.Pdf.Pdf = New Aspose.Pdf.Pdf(fs)

Dim brgraph As Aspose.Pdf.GraphInfo = New Aspose.Pdf.GraphInfo()
brgraph.GraphBorder = New BorderInfo(BorderSide.Bottom, 10.0F)
brgraph.GraphBorder.SetBorderStyle(BorderSide.Bottom, BorderStyle.Double)
'create pdf and set up pdf margins etc

Dim nullText As String = “n/a”
Dim lic As Aspose.Pdf.License = New Aspose.Pdf.License
Try
lic.SetLicense(Server.MapPath("/Licenses/") & “Aspose.Pdf.lic”)
Catch ex As Exception
System.Diagnostics.Debug.WriteLine(ex.ToString)
End Try

With _pdf
.PageSetup.Margin.Left = 20
.PageSetup.Margin.Top = 20
.PageSetup.Margin.Right = 20
.PageSetup.Margin.Bottom = 20
.PageSetup.PageHeight = PageSize.LetterHeight
.PageSetup.PageWidth = PageSize.LetterWidth
.CompressionLevel = 9
End With

'Add a section to the PDF document
Dim _sc As Section = _pdf.Sections.Add()

Dim table As Table = New Table()

_sc.AddParagraph(table)
’ table.ColumnWidths(“100%”)
Dim row As Row = Nothing
Dim cell As Cell = Nothing





row = New Row(table)
table.Rows().Add(row)
cell = row.Cells().Add(“cell - 1”)
'cell.setBorder(New BorderInfo(BorderSide.All.getValue(), 0.5F))






_pdf.Close()

HI,
I am getting a atrange error when i try to add table and row to the Write in file mode.Please help
Object refernce not set to instance.
at Aspose.Pdf.Xml.ᒱ.ᒺ(Pdf Ә, ޸ ޫ)
at Aspose.Pdf.Pdf.Close()
at PDFdisplay.GenerateSumDetailsReportCoveragePDF(String reportID) in C:\TeamProj\Working Branch\ClientWebsites\iMedia_v3.root\iMedia_v3\WebSites\iMedia_v3\PDFdisplay.aspx.vb:line 4311
at PDFdisplay.Page_Load(Object sender, EventArgs e) in C:\TeamProj\Working Branch\ClientWebsites\iMedia_v3.root\iMedia_v3\WebSites\iMedia_v3\PDFdisplay.aspx.vb:line 8274
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Please find the code below :

Dim fs As FileStream = New FileStream("\ABC\Press\SingleSeg-d.pdf", FileMode.Create)



'Instantiate the Pdf instance and pass the file stream object to its constructor

Dim _pdf As Aspose.Pdf.Pdf = New Aspose.Pdf.Pdf(fs)

Dim brgraph As Aspose.Pdf.GraphInfo = New Aspose.Pdf.GraphInfo()
brgraph.GraphBorder = New BorderInfo(BorderSide.Bottom, 10.0F)
brgraph.GraphBorder.SetBorderStyle(BorderSide.Bottom, BorderStyle.Double)
'create pdf and set up pdf margins etc

Dim nullText As String = “n/a”
Dim lic As Aspose.Pdf.License = New Aspose.Pdf.License
Try
lic.SetLicense(Server.MapPath("/Licenses/") & “Aspose.Pdf.lic”)
Catch ex As Exception
System.Diagnostics.Debug.WriteLine(ex.ToString)
End Try

With _pdf
.PageSetup.Margin.Left = 20
.PageSetup.Margin.Top = 20
.PageSetup.Margin.Right = 20
.PageSetup.Margin.Bottom = 20
.PageSetup.PageHeight = PageSize.LetterHeight
.PageSetup.PageWidth = PageSize.LetterWidth
.CompressionLevel = 9
End With

'Add a section to the PDF document
Dim _sc As Section = _pdf.Sections.Add()

Dim table As Table = New Table()

_sc.AddParagraph(table)
’ table.ColumnWidths(“100%”)
Dim row As Row = Nothing
Dim cell As Cell = Nothing





row = New Row(table)
table.Rows().Add(row)
cell = row.Cells().Add(“cell - 1”)
'cell.setBorder(New BorderInfo(BorderSide.All.getValue(), 0.5F))






_pdf.Close()

HI ,
I am also facing the same issue in .net assembly.Please advice
Please find the code below

Please find the code below :

Dim fs As FileStream = New FileStream("\ABC\Press\SingleSeg-d.pdf", FileMode.Create)



'Instantiate the Pdf instance and pass the file stream object to its constructor

Dim _pdf As Aspose.Pdf.Pdf = New Aspose.Pdf.Pdf(fs)

Dim brgraph As Aspose.Pdf.GraphInfo = New Aspose.Pdf.GraphInfo()
brgraph.GraphBorder = New BorderInfo(BorderSide.Bottom, 10.0F)
brgraph.GraphBorder.SetBorderStyle(BorderSide.Bottom, BorderStyle.Double)
'create pdf and set up pdf margins etc

Dim nullText As String = “n/a”
Dim lic As Aspose.Pdf.License = New Aspose.Pdf.License
Try
lic.SetLicense(Server.MapPath("/Licenses/") & “Aspose.Pdf.lic”)
Catch ex As Exception
System.Diagnostics.Debug.WriteLine(ex.ToString)
End Try

With _pdf
.PageSetup.Margin.Left = 20
.PageSetup.Margin.Top = 20
.PageSetup.Margin.Right = 20
.PageSetup.Margin.Bottom = 20
.PageSetup.PageHeight = PageSize.LetterHeight
.PageSetup.PageWidth = PageSize.LetterWidth
.CompressionLevel = 9
End With

'Add a section to the PDF document
Dim _sc As Section = _pdf.Sections.Add()

Dim table As Table = New Table()

_sc.AddParagraph(table)
’ table.ColumnWidths(“100%”)
Dim row As Row = Nothing
Dim cell As Cell = Nothing





row = New Row(table)
table.Rows().Add(row)
cell = row.Cells().Add(“cell - 1”)
'cell.setBorder(New BorderInfo(BorderSide.All.getValue(), 0.5F))






_pdf.Close()

								<br>

Hello Varsha,

Thanks for using our products.

I have tested the scenario using Aspose.Pdf for .NET 5.3.0 in Visual Studio 2008 project over Windows7 Professional X64 and I am unable to notice any problem. The PDF document is properly being generated. Can you please share which version of product you are using. We apologize for your inconvenience.