Free Support Forum - aspose.com

Simple Code doesn't work

I wrote some simple code right out of the docs:

Pdf pdf = new Pdf();
pdf.BindXML(@“c:\invoice.xml”, null);
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType=“application/pdf”;
pdf.Save(Response.OutputStream);
Response.End();

Doesn’t work. I get this crash–>

System.NullReferenceException: Object reference not set to an instance of an object.
at Aspose.Pdf.Document.DocumentWriter.T14(String text)
at Aspose.Pdf.Document.L1.C12(DocumentWriter docWriter)
at Aspose.Pdf.Document.L1.D12(DocumentWriter docWriter)
at Aspose.Pdf.Document.DocumentWriter.B14()
at Aspose.Pdf.Xml.J7.A11(G6 gen, Pdf doc)
at Aspose.Pdf.Xml.K7.C12(G6 gen, Pdf doc)
at Aspose.Pdf.Pdf.Save(Stream stream)
at Banks.reportdownload.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\banks\reportdownload.aspx.cs:line 90
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain()


I also tried using the XmlDocument method where you load the .xml file via an XMLTextReader, Load an XmlDocument pass that into BindXML(). Same thing…

I’ve gone through 5 or 6 <$500 PDF writers in the last few days. This is pretty darn frustrating.

Hi,

Please send a sample of invoice.xml which can reproduce the problem to pdf@aspose.com.

Thanks for your cooperation.