13

ユーザーにプロンプ​​トを表示せずに、WPF FlowDocument を特定のプリンターに印刷しようとしています。プリンターはPDFコンバーターです。

これは、デフォルトのプリンターに印刷されることを除いて、うまく機能します。

   PrintDialog pd = new PrintDialog();
   var doc = ((IDocumentPaginatorSource) RTB.Document).DocumentPaginator;
   // I would like to explicitly set the printer to print to here.
   pd.PrintDocument(doc, "Print Document");

WinForms には、必要なプリンターに設定できる PrinterName プロパティを持つドキュメントに System.Drawing.Printing.PrinterSettings オブジェクトがありますが、WPF には表示されません。

4

2 に答える 2

21

まず、プロジェクトで への参照が必要ですSystem.Printing。次に、オブジェクトを宣言した直後に次のコードを使用できPrintDialogます。

pd.PrintQueue = new PrintQueue(new PrintServer(), "The exact name of my printer");

PrintQueue、プリンターとその印刷キューに関するその他すべてを表すオブジェクトです。

于 2013-04-08T14:44:37.347 に答える
4

共有ネットワークプリンターを使用したとき、これは私にとってはうまくいきました:

xPrintDialog.PrintQueue = New PrintQueue(New PrintServer("\\computer name"), "printer name")
于 2016-03-03T20:41:18.713 に答える