How can i convert doc/docx files to jpgs in ASP.Net. I don't want to install MS Word in server & use interop lib.
Update My scenario is that I need to show Word document pages, page by page to the user in a web page like google docs viewer.
How can i convert doc/docx files to jpgs in ASP.Net. I don't want to install MS Word in server & use interop lib.
Update My scenario is that I need to show Word document pages, page by page to the user in a web page like google docs viewer.
Interop on server/ASP.NET scenario is not supported by MS - see http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2.
There are some 3rd-party libs for this sort of thing without automation and with high-fidelity and several other features (for example from Aspose)...
You may try Aspose.Words for .NET to convert DOC/DOCX to JPEG. It doesn't require MS Office to be installed, or Interop. IT is a .NET assembly which can be used easily in your .NET applications just like any other .NET assembly. It works on 32/64-bit systems seamlessly.
Disclosure: I work as developer evangelist at Aspose.
try this:
using Spire.Doc;
using System.Drawing;
using System.Drawing.Imaging;
namespace Doc2Jpeg
{
class Program
{
static void Main(string[] args)
{
Document doc = new Document();
doc.LoadFromFile("test.doc");
for (int i = 0; i < doc.PageCount; i++)
{
System.Drawing.Image image = doc.SaveToImages(i, Spire.Doc.Documents.ImageType.Metafile);
image.Save(string.Format("result-{0}.jpeg",i), ImageFormat.Jpeg);
}
}
}
}
If you are after a thumbnail image then you can use the Windows explorer thumbnails functionality to generate a thumbnail for a .docx file for you. Full details are on the Stack Overflow question C# get thumbnail from file via windows api.
I'm not sure what components you would need to have installed on the server (word viewer would almost certainly do though, possibly less than that).
If you want something more complex then I suspect you have a difficult task ahead of you.