2009-10-09 5 views
0

Listview에 PDF 파일을 LargeIcon으로 표시하려고합니다. 그러나 그것은 표시되지 않습니다.PDF 파일이 목록보기 C# 2008에 표시되지 않습니다.

모든 이미지 형식을 표시 할 수 있습니다.

ListView에 PDF 파일을 표시하는 방법은 무엇입니까?

이미지 표시처럼 시도했습니다.

private void import(string path) 
{ 

    ListView1.Items.Clear(); 
    ImageList imageList = new ImageList(); 
    imageList.Images.Clear(); 
    imageList.ImageSize = new Size(170, 140); 
    imageList.ColorDepth = ColorDepth.Depth32Bit; 

    int i = 0; 

    ////ArrayList to hold the files with the certain extensions 
    ArrayList files1 = new ArrayList(); 

    if (Directory.Exists(path).Equals(true)) 
    { 
     string validExtensions = "*.pdf"; 

     //create a string array of our filters by plitting the 
     //string of valid filters on the delimiter 
     string[] extFilter = validExtensions.Split(new char[] { ',' }); 

     //loop through each extension in the filter 
     foreach (string extension in extFilter) 
     { 
      files1.AddRange(Directory.GetFiles(path, extension)); 
      files = (string[])files1.ToArray(typeof(String)); 
     } 

     string[] pathes = new string[files.Length]; 

     foreach (string file in files) 
     { 
      pathes[i] = file; 
      i++; 
     } 

     foreach (string path1 in pathes) 
     { 
      imageList.Images.Add(Bitmap.FromFile(path1)); 
      FileInfo fileInfo = new FileInfo(path1); 
      String strDir = fileInfo.Name; 
      ListView1.Items.Add(strDir); 
      ListView1.TileSize = new System.Drawing.Size(100, 80); 
     } 
     for (int j = 0; j < pathes.Length; j++) 
     {     
      this.ListView1.Items[j].ImageIndex = j; 
     } 

     this.ListView1.View = View.LargeIcon; 
     this.ListView1.LargeImageList = imageList; 

     ListView1.Focus(); 
     ListView1.Items[0].Selected = true; 
     } 
    } 
} 
+0

? 기존 코드는 무엇입니까? – SLaks

+1

PDF는 이미지가 아닙니다. 목록보기 안에 PDF 파일의 아이콘을 표시하겠습니까? 목록보기에 PDF 아이콘의 이미지를 추가하면됩니다. –

답변

1

PDF를 래스터 화해야합니다. ImageMagick (아마도 Ghostscript와 함께)이 작업을 수행 할 수 있다고 생각합니다.

면책 조항 : 우리는 여기 이미지에 래스터 PDF에 대한 .NET 라이브러리가

Atalasoft

작동 :

http://atalasoft.com/products/dotimage/pdfrasterizer/

정확하게 표시하려는 어떤
관련 문제