An object reference is invalid


I try to use your evaluation version (1.0.1227.36067)

My code is the following:
Pdf pdf = new Pdf();
string xmlFile = Server.MapPath(ApplicationPath + “/xml/Invoice.xml”); // this is your Invoice.xml file without logo string
pdf.BindXML(xmlFile, null);
HeaderFooter headerFooter = pdf.Sections.GetAt(0).OddHeader;

string fname = getPdfFileName(…
//pdf.Save(Server.MapPath(ApplicationPath + Parameters[“PublishDirectory”] + fname));

When I start this I receive the following error in my browser: An object reference is invalid.
If I use pds.Save (filename) file is successfully created but it cannot be open bt Acrobar Reader, it gives the following error: “There was an error opening this document. There was aproblem reading this document (130)”


Dear spt,

A quick question:

Is your OS non-English or have you set your OS’s Regional Settings to a non-English language? If yes, please download the latest fix and replace the installed Aspose.Pdf.dll with it.

Then try again and let me know what happens.


Thanks for quick answer. I already have this fix.
I solve this problem myself,

The following code is works fine:

Pdf pdf = new Pdf();
string xmlFile = Server.MapPath(ApplicationPath + “/xml/SalesCommission.xml”);
pdf.BindXML(xmlFile, null);

Table adressTable = new Table();
adressTable.IsFirstParagraph = true;
Section section = pdf.Sections.GetAt(0);
if(section.Paragraphs == null) section.Paragraphs = new Paragraphs();
Row row1AdressTable = new Row();
row1AdressTable.Table = adressTable;
adressTable.Rows = new Rows();

Cell cell1Row1AdressTable = new Cell();
cell1Row1AdressTable.FitWidth = 60;
cell1Row1AdressTable.Table = adressTable;
row1AdressTable.Cells = new Cells();
Text text1Cell1Row1AdressTable = new Text(section);
cell1Row1AdressTable.Paragraphs = new Paragraphs();
Segment seg1Text1Cell1Row1AdressTable = new Segment(text1Cell1Row1AdressTable);
text1Cell1Row1AdressTable.Segments = new Segments();
seg1Text1Cell1Row1AdressTable.Content = “TTT”;
seg1Text1Cell1Row1AdressTable.TextInfo.FontName = “Helvetica-Bold”;
seg1Text1Cell1Row1AdressTable.TextInfo.FontSize = 12;
seg1Text1Cell1Row1AdressTable.TextInfo.Color.ColorSpaceType = ColorSpaceType.Rgb;
eg1Text1Cell1Row1AdressTable.TextInfo.Color.RgbColorSpace = System.Drawing.Color.FromArgb(0,0,160);

string fname = getPdfFileName(…);

So, it seems it is necessary to add even one Paragraph. Please, explain.

Note: when I try to start an Invoice example from your demo and comment all lines except

Pdf pdf = new Pdf();
string xmlFile = Server.MapPath(ApplicationPath + “/xml/Invoice.xml”);
pdf.BindXML(xmlFile, null);

I received the same error.