We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Exception converting to OpenOffice

When converting the attached document to OpenOffice, I get the following exception. Converting to other formats seems to work fine. Can you reproduce the problem?

Index was outside the bounds of the array.
SourceAspose.Words
StackTrace: at ?.?.?(Paragraph ?, Boolean ?)
at ?.?.VisitParagraphStart(Paragraph paragraph)
at Aspose.Words.Paragraph.Accept(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.?(DocumentVisitor ?)
at Aspose.Words.Tables.Cell.Accept(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.?(DocumentVisitor ?)
at Aspose.Words.Tables.Row.Accept(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.?(DocumentVisitor ?)
at Aspose.Words.Tables.Table.Accept(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.?(DocumentVisitor ?)
at Aspose.Words.Body.Accept(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.?(DocumentVisitor ?)
at Aspose.Words.Section.Accept(DocumentVisitor visitor)
at ?.?.?()
at ?.?.VisitDocumentStart(Document doc)
at Aspose.Words.Document.Accept(DocumentVisitor visitor)
at ?.?.?()
at ?.?.?()
at ?.?.?(? ?)
at Aspose.Words.Document.Save(Stream stream, SaveFormat saveFormat)

I’m seeing several similar problems with other doucments:

Index was outside the bounds of the array.
SourceAspose.Words
StackTrace: at ?.?.?(Paragraph ?, Boolean ?)
at ?.?.VisitParagraphStart(Paragraph paragraph)
at Aspose.Words.Paragraph.Accept(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.?(DocumentVisitor ?)
at Aspose.Words.Body.Accept(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.?(DocumentVisitor ?)
at Aspose.Words.Section.Accept(DocumentVisitor visitor)
at ?.?.?()
at ?.?.VisitDocumentStart(Document doc)
at Aspose.Words.Document.Accept(DocumentVisitor visitor)
at ?.?.?()
at ?.?.?()
at ?.?.?(? ?)
at Aspose.Words.Document.Save(Stream stream, SaveFormat saveFormat)
TargetSite:Aspose.Words.VisitorAction ?(Aspose.Words.Paragraph, Boolean)

Hi
Thanks for you inquiry. I tried to convert your document to ODT and all works fine on my side. Could you please provide me code that will allow me to reproduce this issue?
Best regards.

We’re converting from our own internal format, so it would be very involved to give you enough code and a test harness for a test case. The Word doc file that I attached was saved successfully by Aspose.Words from the same document of ours. I also re-imported that Word file to our application using Aspose and saved again to ODT, producing the same exception.
In general we construct the document by traversing our document tree, building the Aspose document tree as we go and calling AppendChild at the appropriate times, rather than using DocumentBuilder.
Is there any way we can do more tracing on our end to give you better diagnostics? Perhaps a debug version of your library?

Hi
Are you using the latest version of Aspose.Words? I use Aspose.Words 5.2.0 for testing.
Best regards.

Yes, 5.2.0.0

Unfortunately I can’t reproduce this issue on my side. Please try using the following code:

Document doc = new Document(@"Test245\Do_this.doc");
doc.Save(@"Test245\out.odt", SaveFormat.Odt);

Best regards.

Yes, I tried it with the Document Explorer sample app and I see that that works.
Where can we go from here? I do believe it’s a problem with the Aspose library, or at least a difference in behavior for ODT conversion, given that it works for saving to other formats.
Again, is there a debug version of the library I could try? Or some kind of tracing I can turn on?
Thanks,
Steve

No, there is no debug version of Aspose.Words. Just provide us code that will allow us to reproduce this issue and we will try to help you.
Best regards.

I’m sorry, but as I mentioned, that would be very difficult. Can I escalate this problem to a developer, please?

I’ve walked through our code with the debugger and extracted all the Aspose calls, and from that I’ve hacked together a test case that does reproduce the problem. The code follows:

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using Aspose.Words;
using Aspose.Words.Drawing;
using Aspose.Words.Tables;
using Aspose.Words.Lists;
namespace TestAsposeODTExport
{
    class Program
    {
        static void Main(string[] args)
        {
            Document _toDoc = new Document();
            _toDoc.BuiltInDocumentProperties.Title = "hello";
            _toDoc.BuiltInDocumentProperties.Author = "me";
            _toDoc.BuiltInDocumentProperties.Pages = 1;
            _toDoc.BuiltInDocumentProperties.NameOfApplication = "foo";
            _toDoc.RemoveAllChildren(); // removes default section
            Section _section = new Section(_toDoc);
            _section.ClearHeadersFooters();
            _toDoc.AppendChild(_section);
            Body body = new Body(_toDoc);
            _section.AppendChild(body);
            _section.PageSetup.LeftMargin = 72.0;
            _section.PageSetup.TopMargin = 72.0;
            _section.PageSetup.RightMargin = 72.0;
            _section.PageSetup.BottomMargin = 72.0;
            _section.PageSetup.PageWidth = 612.0;
            _section.PageSetup.PageHeight = 792.0;
            _section.PageSetup.HeaderDistance = 20.0;
            _section.PageSetup.FooterDistance = 20.0;
            addParagraph(_toDoc, body);
            addTable(_toDoc, body);
            addParagraph(_toDoc, body);
            _toDoc.Save("c:\\temp\\test.odt", SaveFormat.Odt);
        }
        static void addParagraph(Document _toDoc, Body body)
        {
            Paragraph asposePara = new Paragraph(_toDoc);
            asposePara.ParagraphFormat.FirstLineIndent = 0.0;
            asposePara.ParagraphFormat.LeftIndent = 0.0;
            asposePara.ParagraphFormat.RightIndent = 0.0;
            TabStop stop = new TabStop(36.0);
            stop.Alignment = TabAlignment.Left;
            asposePara.ParagraphFormat.TabStops.Add(stop);
            asposePara.ParagraphFormat.Alignment = ParagraphAlignment.Left;
            asposePara.ParagraphFormat.LineSpacing = 12.0;
            asposePara.ParagraphFormat.SpaceAfter = 0.0;
            asposePara.ParagraphFormat.SpaceBefore = 0.0;
            body.AppendChild(asposePara);
            Run asposeRun = new Run(_toDoc, "");
            asposeRun.Font.Name = "Times New Roman";
            asposeRun.Font.Size = 12.0;
            asposePara.AppendChild(asposeRun);
        }
        static void addTable(Document _toDoc, Body body)
        {
            Table asposeTable = new Table(_toDoc);
            ((CompositeNode)body).AppendChild(asposeTable);
            Row row = new Row(_toDoc);
            asposeTable.AppendChild(row);
            Cell cell = new Cell(_toDoc);
            row.AppendChild(cell);
            cell.CellFormat.Width = 10.0;
            cell.CellFormat.Shading.BackgroundPatternColor = Color.FromArgb(0xff, Color.FromArgb(-16732372));
            cell.CellFormat.Borders.LineStyle = LineStyle.None;
            cell.CellFormat.Borders.Color = Color.FromArgb(0xff, Color.FromArgb(0));
            cell.CellFormat.LeftPadding = 3.0;
            cell.CellFormat.TopPadding = 3.0;
            cell.CellFormat.RightPadding = 3.0;
            cell.CellFormat.BottomPadding = 3.0;
            Paragraph asposePara = new Paragraph(_toDoc);
            asposePara.ParagraphFormat.FirstLineIndent = 0.0;
            asposePara.ParagraphFormat.LeftIndent = 0.0;
            asposePara.ParagraphFormat.RightIndent = 0.0;
            asposePara.ParagraphFormat.Alignment = ParagraphAlignment.Left;
            asposePara.ParagraphFormat.LineSpacing = 12.0;
            asposePara.ParagraphFormat.SpaceAfter = 0.0;
            asposePara.ParagraphFormat.SpaceBefore = 0.0;
            cell.AppendChild(asposePara);
            Run asposeRun = new Run(_toDoc, "");
            asposeRun.Font.Name = "Times New Roman";
            asposeRun.Font.Size = 12.0;
            asposePara.AppendChild(asposeRun);
        }
    }
}

You can even eliminate the

addTable(_toDoc, body);

and the second call to

addParagraph(_toDoc, body);

… and the array out of bounds exception still occurs.

Thanks a lot for creating a test case. We will address asap.

Hi
This issue #5344 was fixed. I will notify you as soon as release is published.
Best regards.

Any update on a release for this? We would like to get it into our next release, coming soon.
Thanks,
Steve

Hi
Thanks for your inquiry. Release will be published within 1-2 days. I will notify you.
Best regards.

The issues you have found earlier (filed as 5344) have been fixed in this update.

Thanks for the quick turnaround on this fix! We can now release ODT export capability very soon.