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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Getting ArgumentOutOfRangeException during ConvertToPDF

Thread ID:





123979 May 5,2016 11:17 AM UTC May 6,2016 10:48 AM UTC ASP.NET Web Forms 1
Tags: DocIO
Firat Caglar
Asked On May 5, 2016 11:17 AM UTC


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?


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();

            DataTableCollection childTables = ds.Tables;

            foreach (DataTable childTable in childTables)
                if(childTable.TableName != "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.


Attachment: Documents_29274860.zip

Priyanga Elangovan [Syncfusion]
Replied On 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.



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon