Hi,
Can You help to create thumbnail of dynamic content, i have multiple .doc file, i am display data into gridview but
Required is to display thumbnail based on .doc file, how to read data dynamically and generate the thumbnail?
Regards,
Krishan Kumar Singh


Richard Porter34 reputationPosted Mar 2, 2015, 11:23 PM EST
First I defined a GridView control with bound fields like this:
asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"> Columns> asp:BoundField DataField="FileName" /> asp:ImageField DataImageUrlField="FileThumbnailUrl">asp:ImageField> Columns> asp:GridView>var table = new DataTable(); table.Columns.Add(new DataColumn("FileName", typeof(string))); table.Columns.Add(new DataColumn("FileThumbnailUrl", typeof(string))); foreach (var wordFile in Directory.GetFiles(Server.MapPath("~/Sample Files/"), "*.doc")) { string thumbnailFile = wordFile.Replace(".doc", ".png"); DocumentModel.Load(wordFile) .Save(thumbnailFile, new ImageSaveOptions(ImageSaveFormat.Png) { Width = 200, Height = 250 }); table.Rows.Add(Path.GetFileName(wordFile), this.ResolveUrl( Path.Combine("Sample Files", Path.GetFileName(thumbnailFile)))); } this.GridView1.DataSource = table; this.GridView1.DataBind();In short I have a "Sample Files" folder where my DOC files are located and I iterate through each of them and convert them to an image and store the image's URL to DataTable.
For reading the Word files in C# and then converting them to an image format I used this .NET component for Word files processing.
Note that this component can enable to manipulate (open, read and then convert) with DOC files in C# but also you can achive the same manipulation for DOCX files in C# as well.