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

Free Support Forum - aspose.com

Aspose.Words PDF Conversion & 'object reference not set to an instance of an object'


I am looking to use Aspose.Words and Aspose.Pdf to convert Word documents to Pdf. I have downloaded the demos for testing and run the Visual Studio 2005 c# test code below (code1).

The first document I tried to convert returned the error: 'object reference not set to an instance of an object'. (Bus.doc)

The second document had a few issues with formatting (in particular the header) (Coroners Case2.doc).

I have included the word documents and pdf files created from my example as an attachment to this post.

I just need to be confident that your product will successfully convert all documents and do a good job before I purchase it.

The demo versions of Aspose I used were:

Aspose.pdf :

Aspose.words :

Hope to hear from you soon.




private void ConvertDocToPdf(string filename)


// Open the document.

Document doc = new Document(filename);

// ... You can merge data/manipulate document content here.

// Save the document in the Aspose.Pdf.Xml format.

string xmlFile = Server.MapPath("~/temp") + "/convert.xml";

doc.Save(xmlFile, SaveFormat.AsposePdf);

// Read the document into Aspose.Pdf.

Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();

pdf.BindXML(xmlFile, null);

// Instruct to delete temporary image files.

pdf.IsImagesInXmlDeleteNeeded = true;

// This seems to speed up Aspose.Pdf if you convert multiple files in one session.

pdf.IsTruetypeFontMapCached = true;

pdf.TruetypeFontMapPath = System.IO.Path.GetTempPath();

// Produce the PDF file.

pdf.Save(Server.MapPath("~/media") + "/" + System.IO.Path.GetFileNameWithoutExtension(filename) + ".pdf");



I apologize that your acquaintance with the products has started with issues Smile [:)] However, please don't treat them as a show stopper. Let me explain why.

Issue #1. The vast majority of the Microsoft Word documents are read by Aspose.Words with no problems. In order to prove that, we are going to launch the Google-Proof project supposed to test and show the outstanding level of Aspose.Words capabilities. So an error raised during opening a .doc file is a very uncommon thing now. It might happen if something really rare or wrong has been encountered in the binary structure of the document. In your case, it has to do with the INCLUDEPICTURE field located at the top of your document. I have logged this issue as #1325 in our defect database and we will try to fix it as soon as possible.

Issue #2. The problem here is that there are horizontal floating lines in your source documents. The comprehensive shape support has been introduced recently in Aspose.Words 4.0 so there's no enough level of integration with Aspose.PDF in this area yet. Therefore just try to use some substitution such as tables with necessary borders on or, for example, bordered paragraphs to avoid the use of floating lines. I've also logged this as issue #1326 so I hope we will be able to address this problem in the future too.

And thank you for posting Smile [:)]

I fixed the problem with the picture, will release in a few days.

The problem with the line overlapping text is actually caused by Aspose.Pdf. I've requested them to look at it. But to work around I agree with Dmitry, you can just create a table there and assign table borders. Or simply use paragraph borders - it will be the easiest and will work.


With the application I am writing, I will not have control over what format the Word documents are provided in. It will be run on a web site that many people will be using. I can't force the users to adhere to formatting their Word documents in a way that won't crash the website during conversions.

I need the conversion to work 100% every time.

I can accept if there are a few little glitches in the conversion process that means the resultant PDF doesn't exactly match the Word document but can't accept major differences between them and definately not for the conversion process to crash.

Perhaps if the conversion process can't convert something in the Word document, it should step over it and continue with the rest of the document.

With the current issues, it would be hard for me to convince my team to use the controls.



We are trying our best.

Aspose.Words test suite includes over 2700 unit tests and over 2000 test documents already and we do even more (Monster-proofing and Google-proofing Aspose.Words).

Regardless of the number of posts in the Aspose.Words support forums, I'm sure crashes are pretty rare and we fix them quickly. There is much more customers using Aspose.Words without problems and never report a thing.

Crashes occur because Word documents are very complex and their format is not well documented, so the program will encounter things that it never expected to occur and does not know how to handle. Most of the time it will throw PleaseReportException that means report the problem to us. It will improve our understanding of the document format and we will produce a fix quickly.

From my experience, there are sometimes "unlucky areas" where you can encounter bunches of "bad" documents. I don't exactly know how "bad" documents appear, but I guess most of them arise from Microsoft Word users with little experience in Microsoft Word attempting to create complex documents.

Therefore, Aspose.Words is going to work without a hitch for most of the sites, but if you happen to have "bad" documents, you could run into some problems. The best you can do to make sure the Aspose solution is stable for you - get your hands on as many documents you will need to process before going release and process them or zip them up and send to us so we can include them in our tests.

The issue is fixed in the latest version of Aspose.Words for .NET 4.0.2 which is now available for download.