Display Thumbnails For Every Page Of A Document

Got an intresting case a few days back..  which lead me think about the ways of generating thumbnails of all the pages of a document. Now, why would you need it ?? well ..i don't know.. maybe you have an app and you want users to click on the thumbnails of a specific page to load it .. depends, like everything else in the world ..! but yes one thing i know is this *is* a very genuine requirement which many costomers have..as i have seen that there are many customers who come with a requirement of generating thumbnails for the pages of their word document.

If you have this requirement and if you want to do it for the first page, then great ! you've got a prebuilt sample (okay..i lied ! you'll need to customize it ..)http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/shareptthum.asp?frame=true

but ..But .. BUT .. this workaround has a few limitations:

1) It requires that the you've selected "Save preview picture" in the File-Properties dialog,

2) You will only get a preview of the first page in the document.

if you are okay with it ..its simple ! use it ! but if you want to have a preview of all the pages then what do you do .. .. offcourse other then reading this blog ..:)

Here you have two workarounds, depending on the you scenario:

1) Programmatically print the document using a MODI printer saving it as tiff. But this workaround has a big limitation of speed, it takes a long time printing the doc, specially if it has lots of images or lots of pages

2) This workaround is based on a default bookmark "\page" and EnhMetaFileBits property exposed in Word 2003 OM. Here is a partial .NET code that you can use.

byte[] emfData = (byte[])wdApp.Selection.EnhMetaFileBits; 
System.IO.MemoryStream ms = new System.IO.MemoryStream(emfData); 
Metafile mf = new Metafile(ms); 

No, this is no perfect workaround this also has a couple of limitations, but i think this is a lesser of evils :)

(a) As this method selects the page and extracts the EnhMetaFileBits, if does not get the margins of the document.

(b) You can use this method only in Word 2003 and above