Free Support Forum - groupdocs.com

Error index out of bound when converting PDF from docx

I found one more issue that when I have a table in one fields (notesText in OpenWordDocument method) when the converting the document then giving an error index out of bound.
table structure as below
"

 
Platform Team Platform Team
"

the code break on objViewerImageHandler.GetPdfFile(sWordDocPath); in GetPDFFromWord method.

Error details : Index was outside the bounds of the array.
at .( , [] )
at .( )
at .( )
at . ()
at . ()
at .( )
at .( )
at .( )
at .( )
at .( , Int32 , Boolean )
at .()
at .( , Int32 , Boolean , Boolean )
at . ()
at .( , Int32 )
at .( )
at .()
at .( )
at .(Boolean )
at .(Boolean )
at . ()
at .(Document , )
at . ​ (GroupDocsOutputStream )
at .(GroupDocsOutputStream )
at .()
at .(FileDescription , PdfFileOptions )


Report.docx (12.9 KB)

@gaurav90 which version of GroupDocs.Viewer you are using?

I converted your file to PDF and did not get any errors.

@gaurav90

I have checked your issue with GroupDocs.Viewer .NET 21.3 - document converted without any errors.

Source:
table_structure.docx (11.9 KB)
Report_temp.docx (13.0 KB)

Output:
output.pdf (33.2 KB)

 
Platform Team Platform Team

This table is in my word document and I have attached the document which I am converting into the pdf. Report_temp.docx (13.0 KB)

And table structure which is begin used table_structure.docx (11.9 KB)

The Groupdocs.Viewer version is 16.11.0.0. and I have tried with 21 version also.

Table structure is not visible.

i am using below code
public static void GetPDFFromWord(string sWordDocPath, string sPDFDocPath)
{
ViewerImageHandler objViewerImageHandler = new ViewerImageHandler(GroupDocUtilities.GetConfigurations());
try
{
FileContainer objFileContainer = new FileContainer();
objFileContainer = objViewerImageHandler.GetPdfFile(sWordDocPath);
GroupDocUtilities.SaveFile(sPDFDocPath, objFileContainer.Stream);
}
catch (Exception ex)
{

            throw(ex);
        }
        finally
        {
            objViewerImageHandler.ClearCache();
        }
    }

In the last post I have mentioned complete part of code.

To fix the issue please update to the latest version of GroupDocs.Viewer 21.3 and use the following code to convert DOCX to PDF

using(Viewer viewer = new Viewer("Report_temp.docx"))
{
         PdfViewOptions options = new PdfViewOptions("output.pdf");
         viewer.View(options);
}

Here is sample application:
SampleApp.zip (11.5 KB)

And views of source and output documents: