1

Hello I would like to create thumbnail from doc docx, actually I use library Leadtools but I have this error :

ExceptionFilter Leadtools.RasterException: Invalid file format at Leadtools.Codecs.RasterCodecs.CheckExceptions(Int32 code) at Leadtools.Codecs.RasterCodecs.DoLoad(LoadParams loadParams) at Leadtools.Codecs.RasterCodecs.Load(String fileName, Int32 width, Int32 height, Int32 bitsPerPixel, RasterSizeFlags flags, CodecsLoadByteOrder order)

I would like to use an another lib for create the thumbnail.

Yvan
  • 1,081
  • 2
  • 20
  • 27

2 Answers2

2

LeadTools is an image processing library so will fail to process non-image formats like DOCX.

The ability to read the Windows created thumbnail for other files is covered in the existing article;

C#/ASP.NET - Get thumbnail from PDF/DOC files which references the Microsoft documentation here https://msdn.microsoft.com/en-us/library/aa289172.aspx that explains how to get the image. The Microsoft doc explains how to do this in SharePoint but the example is in VB.net so should be easy to follow.

Community
  • 1
  • 1
PhillipH
  • 6,182
  • 1
  • 15
  • 25
  • Thx perfect PhillipH ! – Yvan May 17 '16 at 08:25
  • Your solution generate a standard thumbnail from windows not for example the first page of my word document.. – Yvan May 17 '16 at 08:48
  • A 1 minute google turns up this project which previews DOCX. http://blog.maartenballiauw.be/post/2008/01/11/Preview-Word-files-(docx)-in-HTML-using-ASPNET-OpenXML-and-LINQ-to-XML.aspx. The NTFS thumbnail is the only way of doing this without actually opening and parsing the word document. – PhillipH May 17 '16 at 09:08
  • All the MSDN links now gives error. Excellent job Microsoft for ruining the knowledge base that contributors have built up on multiple sites. – Himalaya Garg Sep 09 '21 at 05:55
0

The phrase about LEADTOOLS being "an image processing library so will fail to process non-image formats like DOCX" is not entirely true. With some formats such as Word, Excel, PowerPoint and PDF files (among others), the toolkit can convert them to images but only if a Document Imaging toolkit is used. Entry-level Imaging Pro cannot load such formats. Also, if the appropriate format codec assembly is missing from the project, you will get "RasterException: Invalid file format".

LEADTOOLS Support
  • 2,755
  • 1
  • 12
  • 12