日期:2014-05-18  浏览次数:20850 次

大家来看看,一命名空间的引用
private Document document;
  private IEnumerator DocPages;
  private ArrayList DocPagesList;
  private const string PrinterName = @"\\sutlej\SamsungM";
  private const string DocLocation = @"E:\a.pdf";
   
  protected void print()
  {
  FileStream file = null;
  DocPagesList = new ArrayList();
  try
  {
  file = new FileStream(DocLocation, FileMode.Open, FileAccess.Read);
  byte[] buffer = new byte[file.Length];
  file.Read(buffer, 0, buffer.Length);
   

  document = new Document(new BinaryReader(new MemoryStream(buffer)));


  for (int i = 0; i < document.Pages.Count; i++)
  {
  DocPagesList.Add(i.ToString());
  }
  DocPages = DocPagesList.GetEnumerator();
  DocPages.Reset();
  if (DocPages.MoveNext())
  {
  PrintDocument oPrintDocument = new PrintDocument();
  PrinterSettings oPrinterSettings = new PrinterSettings();
  PageSettings oPageSettings = new PageSettings();
  oPrinterSettings.PrinterName = PrinterName;
  oPageSettings.Landscape = true;
  oPrintDocument.DocumentName = document.Title;
  oPrintDocument.PrinterSettings = oPrinterSettings;
  oPrintDocument.DefaultPageSettings = oPageSettings;
  oPrintDocument.PrintPage += new PrintPageEventHandler(oPrintDocument_PrintPage);
  oPrintDocument.Print();
  }
  }
  catch (Exception exc)
  {
  //lblResult.Text = exc.Message;
  }
  finally
  {
  file.Close();
  }

  }

上面是一个打印pdf的方法
不知道Document在哪个命名空间中,需要导入什么东西。

------解决方案--------------------
应该是读写pdf的类,你看看读写pdf的控件有那些就知道该引用什么了。