如何使用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;
答案 0 :(得分:1)
Adobe Reader的常见问题解答...
AcroRd32.exe / p pathname - 执行Adobe Reader并显示“打印”对话框。
AcroRd32.exe / t path“printername”“drivername”“portname” - 启动Adobe Reader并打印一个文件,其路径必须完全指定,同时禁止打印对话框。
如果要在不显示打印对话框的情况下打印文件,则应使用第二个选项。
答案 1 :(得分: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-applicat