私はWindowsプログラムを作成しています。私は、ユーザーが定義した時間数でpdfを印刷したいと思っています。私は以下のコードを実行しました。 私のコードの問題はたびに1つのコピーを印刷するだけですが、ユーザーが印刷するコピーの数を設定する必要があります。プリンタからコピーを印刷する方法
int NumOfLabel = 10; /* here for example i set to 10 copy */
Process objProcess1 = new Process();
FileName = @"D:\Project\Document\2320.pdf";
//Print the file
PrintDialog pdi = new PrintDialog();
pdi.PrinterSettings.Copies = (short)NumOfLabel;
if (pdi.ShowDialog() == DialogResult.OK)
{
PrinterName = pdi.PrinterSettings.PrinterName;
/// Set the printer.
AddPrinterConnection(PrinterName);
SetDefaultPrinter(PrinterName);
ProcessStartInfo info = new ProcessStartInfo();
info.Verb = "Print";
info.FileName = FileName;
info.CreateNoWindow = true;
info.WindowStyle = ProcessWindowStyle.Normal;
info.UseShellExecute = true;
objProcess1.StartInfo = info;
objProcess1.Start();
MessageBox.Show("Print done.");
}
//Add the printer connection for specified pName.
[DllImport("winspool.drv")]
private static extern bool AddPrinterConnection(string pName);
//Set the added printer as default printer.
[DllImport("winspool.drv", CharSet = CharSet.Auto, SetLastError = true)]
private static extern bool SetDefaultPrinter(string Name);
私は間違いをしているか、何をする必要があるか教えてください。あなたのコメントと答えをありがとう。
:あなたは、次のコードを試すことができますコピー
の多数を印刷するためにあなたがループする必要
MaximumCopiesプロパティを使用して、プリンタがサポートする最大コピー数を決定します。プリンタでサポートされている最大コピー数を超えて設定すると、最大コピー数のみが出力され、例外は発生しません。 - [source](https://msdn.microsoft.com/en-us/library/system.drawing.printing.printersettings.copies(v = vs.110).aspx) – ChrisF
印刷しようとしていることに注意してくださいPDFファイルに10ページありましたか?代わりに10回印刷したい場合があります – ehh
プリンタが複数のコピーをサポートしていることを確認します。それがループしなければならない場合はループする必要があります – ChrisF