私は静かに画像ファイルを印刷しようとしており、特殊な用紙タイプ(「光沢のあるフォト用紙」)と一定のサイズ(15cmで10cm)で印刷する必要があります。通常のWindows上でPrinterDialogの使用中に用紙の種類を設定するにはどうすればよいですか?
私が選択することができます7印刷ダイアログ:
紙サイズ、
紙品質(例えば - "オート"、 "高"、 "標準"、 "カスタム" )
紙タイプ( "普通紙"、 "光沢写真用紙"、 "写真用紙プラス光沢"、 "写真用紙プロプラチナ"、 "はがき"、等...)
しかし、C#コードでは、PaperSize(6インチの場合は4インチ、= 15cmの場合は10cm)のみを設定しています。
私の問題は....私は紙種類、およびないのPaperSource( "トレイ1"、 "トレイ2"、など)を設定するためのオプションを得るのですか
です私はすべてのプリンタがそれがサポートする独自の用紙タイプを持っていることを知っているので、おそらく私はそれをすべて繰り返す必要があるかもしれませんが、私はちょうどそれを理解できませんでした。
これは私の現在のコードです:
string strPrinterName = "Canon iP4850";
PrintDocument printDoc = new PrintDocument();
// We set the paper size
printDoc.DefaultPageSettings.PaperSize = new PaperSize("PhotoPaper", 400, 600);
// Inside the event i actually draw the image all over the paper by using e.Graphics.DrawImage(...)
printDoc.PrintPage += PrintDocPrintPage;
// Creating the print dialog
PrintDialog dlgPrint = new PrintDialog
{
Document = printDoc
};
// We choose the printer
dlgPrint.PrinterSettings.PrinterName = strPrinterName;
// just to be sure - give the new size of our paper
dlgPrint.PrinterSettings.DefaultPageSettings.PaperSize = new PaperSize("PhotoPaper", 400, 600);
// If the printer is invalid
if (!dlgPrint.PrinterSettings.IsValid)
{
throw new Exception(@"Printer is invalid" + Environment.NewLine + strPrinterName);
}
// Print without showing the dialog
printDoc.Print();
は、事前にすべてに感謝。
イムは、それが不可能であることを言っていないが、そのはかなりであることを行っていません。物理的には、デバイスのDEVMODE構造体(その構造体はプリンタドライバ固有の拡張子を持つ)を取得して、正しい値を設定してから書き戻すことができます。これを行うPrinterSettingsオブジェクトをいくつか助けてくれます。 – user957902
このようなもの[link](http://nicholas.piasecki.name/blog/2008/11/programmatically-selecting-complex-printer-options-in-c-shar/)?私はしようとします... – itsho
はい、あなたがする必要があることをまさにthatsです。 – user957902