【问题标题】:specifying number of pages to print in C#在 C# 中指定要打印的页数
【发布时间】:2011-09-16 11:04:59
【问题描述】:

如何指定打印机和要打印的页数,这是我打印 pdf 文件中所有页面的代码,它始终使用默认打印机。

private void printPDFFile(string fileName)
    {
        PrintDialog pd = new PrintDialog();
        pd.PrinterSettings = new PrinterSettings();

        if (DialogResult.OK == pd.ShowDialog(this))
        {
          Process proc = new Process();
          pd.PrinterSettings.FromPage = 1;
          pd.PrinterSettings.ToPage = 2; 
          pd.PrinterSettings.PrintRange = PrintRange.SomePages;
          proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; //Hide the window.
          proc.StartInfo.FileName = @"C:\Program Files\Foxit Software\Foxit                Reader\Foxit Reader.exe";

          proc.StartInfo.Arguments = "-p \""+ fileName+ "\" \""       +pd.PrinterSettings.PrinterName+"\"";

            proc.StartInfo.CreateNoWindow = true;//!! Don't create a Window.
            proc.Start();
            proc.CloseMainWindow();
        }
    }  

【问题讨论】:

    标签: c# .net pdf printing


    【解决方案1】:

    打印不是在 C# 中完成的,而是从 Foxit Reader 完成的。

    查看its manual (pdf) 以了解控制您所需内容的选项。使用-t <Printer> 打印到特定打印机。不过,您似乎无法打印特定页面,请尝试将-t-n 结合使用。

    【讨论】:

      猜你喜欢
      • 2010-12-08
      • 1970-01-01
      • 1970-01-01
      • 2023-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-26
      • 2015-08-07
      相关资源
      最近更新 更多