-1

如何使用pdfsharp在c#中打开打印对话框?这是我打印文档的代码,但它没有打开打印对话框

            Process proc = new Process();
            proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            proc.StartInfo.Verb = "print";

            //Define location of adobe reader/command line
            //switches to launch adobe in "print" mode
            proc.StartInfo.FileName =
              @"C:\Program Files\Adobe\Reader 11.0\Reader\AcroRd32.exe";
            proc.StartInfo.Arguments = String.Format(@"/p /h {0}", pdfFileName);
            proc.StartInfo.UseShellExecute = false;
            proc.StartInfo.CreateNoWindow = true;

            proc.Start();
            proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            if (proc.HasExited == false)
            {
                proc.WaitForExit(10000);
            }

            proc.EnableRaisingEvents = true;

            proc.Close();
            KillAdobe("AcroRd32");
            return true;
4

2 回答 2

1

Adobe Reader 常见问题解答中的逐字记录...

AcroRd32.exe /p 路径名 — 执行 Adob​​e Reader 并显示“打印”对话框。

AcroRd32.exe /t path "printername" "drivername" "portname" — 启动 Adob​​e Reader 并打印一个必须完全指定其路径的文件,同时禁止打印对话框。

如果要在不显示打印对话框的情况下打印文件,则应使用第二个选项。

于 2013-09-17T12:57:15.750 回答
0

我想你正在寻找这个。

  System.Windows.Controls.PrintDialog dialogue = new System.Windows.Controls.PrintDialog();

  DialogResult dr = dialogue.ShowDialog();
  if( dr == DialogResult.OK)
   {
  // Do something
   }

   dialogue.Dispose();

或者

        PrintDocument pd = new PrintDocument();
        pd.PrintPage += new PrintPageEventHandler(PrintPage);
        PrintDialog pdi = new PrintDialog();
        pdi.Document = pd;
        if (pdi.ShowDialog() == DialogResult.OK)
        {
            pd.DocumentName = documentName;
            pd.Print();
        }
        else
        {
           MessageBox.Show("Print Cancelled");
        }

http://www.codeproject.com/Questions/289705/how-to-open-print-dialog-box-in-my-csharp-applic

于 2013-09-17T12:26:10.547 回答