【问题标题】:How to show thumbnail of pdf in listview C#.net?如何在 listview C#.net 中显示 pdf 的缩略图?
【发布时间】:2009-10-14 05:45:30
【问题描述】:
ImageList imageList = new ImageList();
                if (folder != null && System.IO.Directory.Exists(folder))
                {
                    try
                    {
                        string[] arrImageName=new string[1000];
                        int Count = 0;
                        string CutName;
                        DirectoryInfo dir = new DirectoryInfo(@folder);
                        foreach (FileInfo file in dir.GetFiles())
                        {
                            try
                            {

                                imageList.ImageSize = new Size(140, 140);
                                imageList.ColorDepth = ColorDepth.Depth32Bit;
                                Image img1 = Image.FromFile(file.FullName);
                                CutName = file.FullName;
                                CutName = CutName.Replace(folder, "");
                                CutName = CutName.Replace("\\", "");
                                arrImageName[Count] = CutName;
                                imageList.Images.Add(FormatImage(imageList.ImageSize.Width, img1));                              
                                Count = Count + 1;
                            }
                            catch
                            {
                                Console.WriteLine("This is not an image file");
                            }     
                        }


                        for (int j = 0; j < imageList.Images.Count; j++)
                        {
                            this.ListView1.Items.Add((j + 1) + "/" + imageList.Images.Count + " " + "\r\n" + arrImageName[j]);                                
                            this.ListView1.Items[j].ImageIndex = j;
                        }

                        this.ListView1.View = View.LargeIcon;
                        this.ListView1.LargeImageList = imageList;
                        //import(folder);
                    }
                    catch (Exception ex)
                    {

                    }
                } 

【问题讨论】:

    标签: c# pdf listview bitmap


    【解决方案1】:

    你不能这样做

     Image img1 = Image.FromFile(file.FullName);
    

    因为 PDF 不是图像格式,.NET 无法理解。

    这里是thread,介绍如何使用 3rd 方库将 PDF 转换为图像

    【讨论】:

    • 用户 AcroPDFLib 是否有可能解决这种情况。
    • 我不知道,我以前从未使用过 AcroPDFLib。试一试:)
    猜你喜欢
    • 1970-01-01
    • 2011-02-21
    • 1970-01-01
    • 2021-08-10
    • 1970-01-01
    • 2010-12-16
    • 2012-11-19
    • 2011-07-01
    • 2018-04-22
    相关资源
    最近更新 更多