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.
Unfortunately, activation email could not send to your email. Please try again.

Getting ArgumentOutOfRangeException during ConvertToPDF

Thread ID:

Created:

Updated:

Platform:

Replies:

123979 May 5,2016 07:17 AM May 6,2016 06:48 AM ASP.NET Web Forms 1
loading
Tags: DocIO
Firat Caglar
Asked On May 5, 2016 07:17 AM

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

Priyanga Elangovan [Syncfusion]
Replied On May 6, 2016 06:48 AM

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
 


CONFIRMATION

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.

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.

;