Adding Image in nested table failed

Sep 16, 2014 at 9:14 PM
Edited Sep 16, 2014 at 9:20 PM
Hi all,

Can you please help me on this?
When try to add an image to a single table using the following code everything is working.

DocX template = DocX.Load(@"ReportTemplate.docx"); Table configurationTable = template.InsertTable(1, 1);
configurationTable.AutoFit = AutoFit.Window;
Paragraph upperParagraph = configurationTable.Rows[0].Cells[0].Paragraphs[0];
Novacode.Image sideImage = template.AddImage(@"C:\ProgramData\sideImage.png"); upperParagraph.AppendPicture(sideImage.CreatePicture()); --------------------But when i add a child table to a parent table, adding image to child table is failing throwing the following message: Object reference not set to an instance of an object.

The code i used for nested table is the following:
DocX template = DocX.Load(@"ReportTemplate.docx"); Table configurationTable = template.InsertTable(1, 1);
configurationTable.AutoFit = AutoFit.Window;
// Create nested table
Table barrierTable = configurationTable.Rows[0].Cells[0].InsertTable(2, 2);
Novacode.Image sideImage = template.AddImage(@"C:\ProgramData\sideImage.png"); barrierTable.Rows[0].Cells[0].Paragraphs[0].AppendPicture(sideImage.CreatePicture());

I will appreciate if someone help me on this please.
Thanks
Sep 18, 2014 at 1:15 PM
Hmm, your code works for me. Are you using the latest source code for your project?
If not, you could try using the latest source code. If you are (or if it doesn't fix your problem) it might have something to do with your template.
Sep 19, 2014 at 6:25 AM
Problem solved.
Thanks