"Index out of range" error converting Word to PDF


#1

I'm currently evaluating .Words and .PDF.

I've successfully done several Word to PDF conversions using this code:

-----------------------------

Document doc = new Document(values.DocumentName);

MemoryStream ms = new MemoryStream();

doc.Save(ms, SaveFormat.FormatAsposePdf);

ms.Seek(0, SeekOrigin.Begin);

XmlDocument xmlDoc = new XmlDocument();

xmlDoc.Load(ms);

Pdf pdfDoc = new Pdf();

pdfDoc.IsImagesInXmlDeleteNeeded = true;

pdfDoc.BindXML(xmlDoc, null);

pdfDoc.Save("MyForm.pdf", Aspose.Pdf.SaveType.OpenInBrowser, HttpContext.Current.Response);

-------------------------

However, I just tried it with another (very simple) Word to PDF conversion and I got this error:

Index was outside the bounds of the array.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IndexOutOfRangeException: Index was outside the bounds of the array.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[IndexOutOfRangeException: Index was outside the bounds of the array.]
   ෝ.ᐈ.get_࣓(Int32 ࢏) +51
   ෝ.ᖿ.ᗁ(Pdf Ꮨ, Section ዳ, Cell ᒞ, ᓹ ᓯ, XmlTextReader ჱ) +4695
   ෝ.ᘌ.ᘍ(Pdf Ꮫ, XmlTextReader ჱ) +6107
   ෝ.᛬.Ꮩ(Ꮣ ᎘, XmlTextReader ჱ) +6707
   ෝ.Ꮣ.Ꮮ(XmlTextReader Ꮯ) +94
   ෝ.Ꮣ.Ꮭ(XmlDocument Ꮫ, XslTransform Ꮬ) +131
   Aspose.Pdf.Pdf.BindXML(XmlDocument xmlDoc, String xslFile) +74
   FormsMain.LaunchBlankForm(String fileName, String format) +390
   ViewForm.DisplayForm(String formName, String prefill, String format) +789
   ViewForm.Page_Load(Object sender, EventArgs e) +305
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +47
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061

Any Idea what this might be?

Thanks


#2

Hi,

Thank you for considering Aspose.

Please attach the Word document that can reproduce this error.


#3

Thanks for considering Aspose.

I tested MyForm.doc, everything works well.

Aspose.Words v3.5.1.0 Aspose.Pdf v2.9.3.0

// New a Doc object.
Document doc = new Document("MyForm.doc");

// Save the doc in a xml fille that can be handled by Aspose.Pdf.
doc.Save("MyForm.xml", SaveFormat.FormatAsposePdf);

//New a pdf object.
Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();

// Bind content from the named xml file.
pdf.BindXML("MyForm.xml", null);

//Save the document
pdf.Save("MyForm.pdf");


#4

Sorry! I didn’t realize a hotfix had been released. I downloaded the hotfix and the error went away. Thanks.