Free Support Forum -

Crash on Export to PDF

Using the following really simple code:

Dim ap As New Aspose.Word.Document(Filename)
ap.Save(Filename.Replace(".doc", ".xml"), Aspose.Word.SaveFormat.FormatAsposePdf)

I get the following error when I call the "Save" function:

An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll
Additional information: Index was out of range. Must be non-negative and less than the size of the collection.

You can see the document I am using at:

Please let me know if this is a problem with my document or with Aspose.Word.


The problem is caused by somewhat damaged internal structure of the document, one paragraph uses font code that is not defined for the document. I’ve fixed this in Aspose.Word 2.0 which I will release shortly - it is tolerant for invalid font codes.

Another problem in your document is the second picture (Adobe something) that is even not shown when you open the document in MS Word. The picture must be in some invalid format and Aspose.Pdf crashes when trying to open this picture. I tried, the picture is indeed in unrecognizable format. Please delete this picture from the document and insert a valid one.

After you upgrade to Aspose.Word 2.0 (due out shortly) and delete the invalid picture, the file will be converted without exceptions. Please note however, that there are still some formatting issues during conversion. Please report back if there are some differences between DOC and PDF that are not acceptable and we will have a look.

Thanks Roman for your time investigating this matter.

Three questions now:

1) Can you tell me exactly which paragraph is using the bad font code?

2) Can you tell me the exact location of the “second picture” (I’m not quite sure of which you are talking about.

3) Rather than Aspose.Word 2.0, do you mean 3.0? Or 2.1.15? And generally when I can expect the version that will handle invalid font codes (hours, days, weeks, months?).

Thanks again

We will release Aspose.Word 2.0 that canhandle invald font code later today.

Invalid font code is for the paragraph on the first page “Your #1 Source for Property…”, but it could only be just the first occurrence of such problem - I did not check the rest of the document for it.

The invalid picture is on the first page, to the left of “This report satisfies the seller’s …”