Free Support Forum -

ASP.NET Word to PDF Conversion

Is it possible to convert an existing word document that resides on the Web Server into a PDF file using ASPOSE.PDF? Do you have a sample ASP.NET example that would take a Word Document and convert it to a PDF doc on the server? I couldn’t find any examples but saw an old reference in the Forums that it was a work in progress. Is it available?<?xml:namespace prefix = o ns = "urnTongue Tiedchemas-microsoft-comSurprisefficeSurpriseffice" /><oStick out tongue></oStick out tongue>

<oStick out tongue> </oStick out tongue>

Thanks, David

Dear David,

Thank you for considering Aspose.

Please refer to BindHTML, WordToPDF . There is an example in that thread. Maybe I should add this into the programmer’s guide.

The example that you directed me to is below. I put it in a button click event to test it. It does not work. The error message is included as comments.
Also the example produces a warning message…

Could you please take a look at what is published is correct or requires updating. If not, do you have an example that simply takes an existing Word document and converts it to a PDF format.

My confidence about buying a suite of products is shaken when a simple demo dosen’t work. Please help.

using Aspose.PDF;
using Aspose.Word;

private void Button1_Click(object sender, System.EventArgs e)


Word word = new Word();

Document doc = word.Open(@“C:\Temp\WordOutput.doc”); //<-- warning message states that this is obsolete


Pdf pdf = new Pdf();



//Produces the following error…

// C:\Temp\WordOutput.doc already exists

//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.Exception: C:\Temp\WordOutput.doc already exists


//Source Error:



//Line 54: {

//Line 55: Word word = new Word();

//Line 56: Document doc = word.Open(@“C:\Temp\WordOutput.doc”);

//Line 57: doc.Save(“C:/temp/WordOutput.xml”,SaveFormat.FormatAsposePdf);

//Line 58: Pdf pdf = new Pdf();




Hi David,

Sorry I don’t know Aspose.Word has changed it’s API interface in the new version. The new code should like the following:

Document doc = new Document(“letter.doc”);

Pdf pdf = new Pdf();

Thank you for the support. I’m really impressed with the speed of the conversion. I am using the following VB code that uses a memory stream rather than an intermediate file so it could run as a WS. Would I run into problems if I use encoding.ASCII in the loadXML statement?

Also, I tested with Word document that had a colored background and highlighted text. It did not convert. Is this because I am using the demo version of 1.9.2

Thanks for the support.


Dim InPath As String = inUNC.Trim

Dim OutPath As String = outUNC.Trim

Dim mStreamXML As MemoryStream = New MemoryStream

Dim xmlDoc As System.Xml.XmlDocument = New System.Xml.XmlDocument

Dim objDocument As WORD.Document = New WORD.Document(InPath)

objDocument.Save(mStreamXML, WORD.SaveFormat.FormatAsposePdf)


Dim objPDF As PDF.Pdf = New PDF.Pdf

objPDF.BindXML(xmlDoc, Nothing)


Dear Dave,

Thank you for considering Aspose.

LoadXml is a .NET method and you can look at it’s documentation. I think using Encoding.ASCII will not cause problem is you don’t use unicode.

The evaluation version of Aspose.Pdf has full features.
Some advanced features in Word is not supported in Aspose.Pdf. But colored background should be supported. You can send me the Word document if it has problem to convert to PDF.


I am storing word document in database. Do you have any sample code to convert database stored word document into PDF document.

Also you have any idea, how to create rich text control using ASP.Net application.


Dear sfgroups,

Thank you for considering Aspose.

I have no example of converting database stored word document to pdf document. But I think there is no difference if you can open the word document in database using Aspose.Word.

I am not familiar with rich text control in Asp.Net and can’t give you any advice.