I have 2 problems when I want to print more than one copy and choosing a tray.
I create a loop to solve the number of copies.
It seems that the following code does not work, may be you have a solution:
- Code: Select all
this.pdfDocumentViewer1.PrintSettings.Copies = dialogPrint.PrinterSettings.Copies;
Then I could not find a way to tell pdfDocumentviwer which tray I chose
- Code: Select all
private void tsBtnPrint_Click(object sender, EventArgs e)
{
try
{
PrintDialog dialogPrint = new PrintDialog();
dialogPrint.AllowSomePages = false;
dialogPrint.AllowCurrentPage = false;
dialogPrint.AllowSelection = false;
dialogPrint.PrinterSettings.MinimumPage = 1;
dialogPrint.PrinterSettings.MaximumPage = this.pdfDocumentViewer1.PageCount;
dialogPrint.PrinterSettings.FromPage = 1;
dialogPrint.PrinterSettings.ToPage = this.pdfDocumentViewer1.PageCount;
dialogPrint.PrinterSettings.PrinterName = "";
//var pSource = dialogPrint.PrinterSettings.PaperSources;
//for (int i = 0; i < dialogPrint.PrinterSettings.PaperSources.Count; i++)
//{
// var pkSource = dialogPrint.PrinterSettings.PaperSources[i];
//}
if (dialogPrint.ShowDialog() == DialogResult.OK)
{
Cursor.Current = Cursors.WaitCursor;
if (dialogPrint.PrinterSettings.Copies > 1)
{
for (int i = 0; i < dialogPrint.PrinterSettings.Copies; i++)
{
PrintController standard = new StandardPrintController();
this.pdfDocumentViewer1.PrintSettings.PrintController = standard;
this.pdfDocumentViewer1.PrintSettings.PrinterName = dialogPrint.PrinterSettings.PrinterName;
this.pdfDocumentViewer1.PrintSettings.DocumentName = "Print Document";
//for (int i2 = 0; i2 < dialogPrint.PrinterSettings.PaperSources.Count; i2++)
//{
// var pkSource = dialogPrint.PrinterSettings.PaperSources[i2];
//}
this.pdfDocumentViewer1.PrintSettings.Copies = dialogPrint.PrinterSettings.Copies;
this.pdfDocumentViewer1.PrintSettings.Duplex = dialogPrint.PrinterSettings.Duplex;
this.pdfDocumentViewer1.PrintDoc();
}
}
else
{
PrintController standard = new StandardPrintController();
this.pdfDocumentViewer1.PrintSettings.PrintController = standard;
this.pdfDocumentViewer1.PrintSettings.PrinterName = dialogPrint.PrinterSettings.PrinterName;
this.pdfDocumentViewer1.PrintSettings.DocumentName = "Print Document";
this.pdfDocumentViewer1.PrintSettings.Copies = dialogPrint.PrinterSettings.Copies;
this.pdfDocumentViewer1.PrintSettings.Duplex = dialogPrint.PrinterSettings.Duplex;
this.pdfDocumentViewer1.PrintDoc();
}
}
Cursor.Current = Cursors.Default;
}
catch (Exception ex)
{
Cursor.Current = Cursors.Default;
MessageBox.Show(ex.Message);
}
}
OS is win10, Spire.PdfViewer.Forms 7.1.4.0 (Not free version)
Thank you in advance
Best regards
Hossein