We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Getting ArgumentOutOfRangeException during ConvertToPDF

Hi, 

I'm trying to generate pdf documents from docx templates. I filled this docx templates with xml data and then convert generated docx document to pdf. I use mail merge to generate.
When I'm trying to convert to pdf the generated word document with Tables (by the way, as you'll see I use ExecuteGroup method to fill table with data), I got ArgumentOutOfRangeException (Length cannot be less than zero).

On the other hand, when I generate document 'without' table and use Execute mailmerge method, I'm able to successfully convert generated document to pdf with ConvertToPDF() method. 

I attached docx template, the xml data and the code I use for generate document. Am I doing something wrong?

Code:

DocToPDFConverter docToPdfConverter = new DocToPDFConverter();

            WordDocument document = new WordDocument();
            document.Open(templateFilePath + "TemplateWithTable.docx");

            document.MailMerge.MergeImageField += MailMergeOnMergeImageField;

            XDocument xmlDoc = null;

            using (StreamReader oReader = new StreamReader(templateFilePath + "XMLData.xml", Encoding.GetEncoding("ISO-8859-9")))
            {
                xmlDoc = XDocument.Load(oReader);
            }

            //data get from db as xml file
            DataSet ds = new DataSet();
            
            ds.ReadXml(xmlDoc.CreateReader());

            DataTableCollection childTables = ds.Tables;

            foreach (DataTable childTable in childTables)
            {
                if(childTable.TableName != "root")
                {
                    document.MailMerge.ExecuteGroup(childTable);    
                }
            }

            document.MailMerge.Execute(childTables["root"]);

            document.Save(templateFilePath + "GeneratedDocument.doc");

            //I get the exception on this line!
            PdfDocument pdfDocument = docToPdfConverter.ConvertToPDF(templateFilePath + "GeneratedDocument.doc");
            pdfDocument.Save(templateFilePath + "GeneratedDocument.pdf");

Thanks for your help.

Caglar

Attachment: Documents_29274860.zip

1 Reply

PE Priyanga Elangovan Syncfusion Team May 6, 2016 10:48 AM UTC

Hi Firat,

Thank you for contacting Syncfusion support.

We are able to reproduce the mentioned exception issue in Word to PDF conversion, we will fix this exception issue and the fix will be available in our 2016 volume 2 major release which is expected to be available in the mid of June 2016.

Regards,
Priyanga
 


Loader.
Live Chat Icon For mobile
Up arrow icon