Sign In  Sign Up Live-Chat

Index was outside the bounds of the array.

Last post 08-14-2008, 5:16 AM by alexey.noskov. 59 replies.
Page 1 of 4 (60 items)   1 2 3 4 Next >
Sort Posts: Previous Next
  •  05-16-2008, 9:04 AM 127433

    Index was outside the bounds of the array.

    Attachment: Present (inaccessible)

    I'm using Aspose.Words for converting DOCX files to PDF using this method:

             internal static void MakeAsposePdf(FileInfo wordDocumentPath, FileInfo pdfDocumentPath)
            {
                License licenseWords = new License();
                licenseWords.SetLicense("Aspose.Words.lic");

                Aspose.Pdf.License licensePdf = new Aspose.Pdf.License();
                licensePdf.SetLicense("Aspose.Pdf.lic");

                // Open the DOC file using Aspose.Words.
                Document doc = new Document(wordDocumentPath.FullName);

                // ...You can merge data/manipulate document content here.
                // Save the document in Aspose.Pdf.Xml format.
                doc.Save(FileLocations.GeneratedFiles + "
    \\MyDocument.xml", SaveFormat.AsposePdf);

                // Read the document in Aspose.Pdf.Xml format into Aspose.Pdf.
                Pdf pdf = new Pdf();
                pdf.BindXML(FileLocations.GeneratedFiles + "
    \\MyDocument.xml", null);

                // Instruct to delete temporary image files.
                pdf.IsImagesInXmlDeleteNeeded = true;
                pdf.CompressionLevel = 0;

                // Produce the PDF file.
                pdf.Save(pdfDocumentPath.FullName);
            }

    But then I get this error:


    Message: Index was outside the bounds of the array.
    Stacktrace:    at ?.?.?()
       at ?.?..ctor(Table tableNode, Boolean resolveInheritedBorders, Boolean populateEmptyPadBorders)
       at ?.?.?(Table ?)
       at ?.?.VisitTableStart(Table table)
       at Aspose.Words.Tables.Table.Accept(DocumentVisitor visitor)
       at Aspose.Words.CompositeNode.?(DocumentVisitor ?)
       at Aspose.Words.Body.Accept(DocumentVisitor visitor)
       at ?.?.?(Section ?)
       at ?.?.?(? ?)
       at Aspose.Words.Document.?(Stream ?, String ?, SaveFormat ?)
       at Aspose.Words.Document.Save(String fileName, SaveFormat fileFormat)

    I've attached the DOCX file I'm trying to convert.

    Any suggestions?

     
  •  05-16-2008, 9:17 AM 127436 in reply to 127433

    Re: Index was outside the bounds of the array.

    Hi

     

    Thanks for your request. I can’t reproduce this issue on my side. I use the latest versions of Aspose.Words Aspose.Pdf for testing. You can download them from here.

    http://www.aspose.com/community/files/51/file-format-components/aspose.words/entry127076.aspx

    http://www.aspose.com/community/files/51/file-format-components/aspose.pdf/entry113366.aspx

     

    Best regards.


    Alexey Noskov
    Developer/Technical Support
    Aspose Auckland Team
     
  •  05-18-2008, 4:16 AM 127560 in reply to 127436

    Re: Index was outside the bounds of the array.

    Thanks...

    But I tried downloading from the links you provided, but the error still occurs. Did you use the attached docx and use the C# snippet above?

    Can you attach the cenverted PDF - I'm just curious how it looks :-)

     
  •  05-18-2008, 5:53 AM 127567 in reply to 127560

    Re: Index was outside the bounds of the array.

    Hello!

     

    There is no exception on the current versions. Maybe you have installed the new libraries but your application is still bound to the old once. As I can see from the stack dump the exception should occur in Aspose.Words. Please check your project again. Maybe you need to reference another DLL and invoke “rebuild all” command.

     

    I’m trying to attach the result PDF. I hope there is nothing secret. But it is huge even in archive and our forum hangs on file uplooad. It would be better to send the PDF by e-mail. Please provide me an address.

    I can also send the intermediate output if it is curious.

     

    Regards,
    Viktor Sazhaev
    Software Engineer, Aspose Auckland Team
     
  •  05-18-2008, 7:51 AM 127571 in reply to 127567

    Re: Index was outside the bounds of the array.

    OK - I've send you my e-mail address...

     
  •  05-19-2008, 9:44 AM 127696 in reply to 127571

    Re: Index was outside the bounds of the array.

    Hello!

     

    Thank you for additional materials.

     

    I’m able to reproduce the exception on the original document “a3test.docx” from your archive. The issue is logged as #5164 in our defect database. When I re-saved it with MS Word again in DOCX format it became convertible. You can try this too. When I’m converting the DOC file these barcodes get crowded. To spot this I should first investigate and fix the issue with exception. Maybe there is some format deviation in the document.

     

    Note that cell spacing and autofit to content size are not supported in PDF conversion. We already discussed these two features with Aspose.Pdf Team and hopefully they will support autofit soon. You can play with cell padding values to achieve the same result if you just want to distribute contents of adjacent cells.

     

    That’s still not clear for me why you need so huge image files. Shall I try converting them to PNG of smaller size without quality penalty? JPEG is intended primarily for photo images, not for tables and text.

     

    Regards,
    Viktor Sazhaev
    Software Engineer, Aspose Auckland Team
     
  •  05-20-2008, 3:13 AM 127808 in reply to 127696

    Re: Index was outside the bounds of the array.

    Hi Viktor

    I’m somehow glad to hear, you can reproduce the error. That makes me look less foolish :-)

    I wasn’t able to process the docx file by resaving it. Did you mean that I should open the original docx in Word, choose Save As and save it with a different docx filename?

    The large image files are only remnants from my numerous attempts to convert using the Microsoft Office Add-in: Microsoft “Save as PDF” (http://msdn.microsoft.com/en-us/library/bb412305.aspx) without the enormous compression. So you don’t have to convert them – I just haven’t got to that yet.

    I’m looking forward to hear from you regarding the exception.

    Best regards,
    Brian

     
  •  05-20-2008, 8:10 AM 127866 in reply to 127808

    Re: Index was outside the bounds of the array.

    I got the file you sent me and I've maybe figured out why it works when you've re-saved the file, because now all controls for inserting text programmatically is gone :-)

    Although this is not a solution as we'll have to have to the placeholders in the document, how did you manage to save the file and loose the controls?

    This is probably why it works when saving it as Word97 - then the controls are also converted into static text.

     
  •  05-20-2008, 8:25 AM 127868 in reply to 127808

    Re: Index was outside the bounds of the array.

    Hello Brian!

     

    I have uploaded the round-tripped file to accessible storage and provided you a link. Please download and try converting it. On my side that’s okay.

     

    Technical reason of the exception (issue #5164) is that some cells in the first table in main story (not in the header) have zero width attribute. MS Word calculates width from so-named preferable width. I tried to fix this case by analyzing other cell attributes but there is still no luck. I’m unable to cover all similar cases. We’ll investigate the problem further and will inform you on any progress. But it would be great if we find and steady workaround for that.

     

    Please let me know how you created that document. Is there any specific?

     

    Regards,
    Viktor Sazhaev
    Software Engineer, Aspose Auckland Team
     
  •  05-20-2008, 9:05 AM 127877 in reply to 127868

    Re: Index was outside the bounds of the array.

    Sorry if anything is lost. I used MS Office compatibility pack. Anyway now the reason is known and you can check whether and why those cells have zero width. CellFormat.Width will return zero for them. You can eliminate the problem in your original document.

     

    If you are inserting parameterized contents into documents it’s better to utilize mail merge or bookmarks. I see only the fragment that performs conversion in the beginning of the thread. Please also share the code inserting parameterized contents and we’ll try other possibilities.

     

    Regards,
    Viktor Sazhaev
    Software Engineer, Aspose Auckland Team
     
  •  05-21-2008, 6:14 AM 128010 in reply to 127877

    Re: Index was outside the bounds of the array.

    Attachment: Present (inaccessible)

    Hi Viktor

    I’ve created the document in Word 2007 and inserted content controls from the Developer tab as pictured in insert_a_plain_text_content_control.png.
    Then I’m opening the document using the Open XML API (very much like described here: http://msdn.microsoft.com/en-us/library/bb508261.aspx) and modifying the XML by adding and replacing content.

    I’m perfectly ok with programmatically converting the docx to doc to be able to convert it into PDF, but the problem with the table formatting still remains. I’ll try to achieve the correct formatting by setting some other attributes as you mentioned earlier.

    Best regards,

    Brian

     
  •  05-21-2008, 7:36 AM 128025 in reply to 128010

    Re: Index was outside the bounds of the array.

    Hello!

     

    Okay, that would be great if every cell will specify Width attribute as I wrote. Please also ensure that after manipulations with Open XML API your document is still correct.

     

    Regards,
    Viktor Sazhaev
    Software Engineer, Aspose Auckland Team
     
  •  05-22-2008, 2:55 AM 128188 in reply to 128025

    Re: Index was outside the bounds of the array.

    I found out why the formatting was corrupted! I set the cell width in each cell
    (/w:tbl/w:tr/w:tc) but I didn’t duplcate the column specification with the width attribute (/w:tbl/w:tblGrid/w:gridCol) so that it gridCol count matches the tc count.

    Apprently the “Save as PDF” add-in don’t bother, but you guys do :-)

     
  •  05-22-2008, 5:57 AM 128221 in reply to 128188

    Re: Index was outside the bounds of the array.

    Hello Brian.

     

    Thank you for clarification. I agree that’s not good if Aspose.Words cannot put up with this format deviation while other tools can. We’ll investigate the issue further. Even if some document is not 100% correct at minimum we try to avoid crash on it. As I wrote I had some ideas but they broke another test from our test database. In some cases cells with zero Width should be ignored completely but in other cases they should be output. Currently I cannot form proper criteria.

     

    Best regards,
    Viktor Sazhaev
    Software Engineer, Aspose Auckland Team
     
  •  05-22-2008, 3:54 PM 128311 in reply to 128221

    Re: Index was outside the bounds of the array.

    Attachment: Present (inaccessible)

    Hi Viktor

     

    Just as I thought my formatting problems was over, I discovered another one J

    In the attached docx and doc documents the text in the cells in the table at the very top are aligned centered vertically. E.g. the “2010-03” is placed in the middle of the hourglass.

    But in the generated PDF the first nine cells in the bottom row are top aligned! Can you see why that is? Does it have something to do with the cell merging? Would it be possible to solve it?

     

    Thanks in advance,

    Brian

     

     
Page 1 of 4 (60 items)   1 2 3 4 Next >
View as RSS news feed in XML