Spire.DocViewer for .NET is a powerful Word Viewer component for developers to display, convert and interact with Word Documents easily.

Mon May 09, 2022 12:32 pm

Hi
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

hossein9
 
Posts: 4
Joined: Mon Apr 28, 2014 5:12 pm

Tue May 10, 2022 11:24 am

Hi,

Thank you for your inquiry.
Please refer to the following code. If you have any further questions, please feel free to contact me.
Code: Select all
            this.pdfDocumentViewer1.LoadFromFile("filename");
            this.pdfDocumentViewer1.PrintSettings.PrinterName = "printerName";
            this.pdfDocumentViewer1.PrintSettings.Copies = number;
            this.pdfDocumentViewer1.PrintSettings.PaperSettings += delegate (object sender1, PdfPaperSettingsEventArgs e1)
            {
                //Set the paper source of page 1-2 as tray 1
                if (1 <= e1.CurrentPaper && e1.CurrentPaper <= 2)
                {
                    e1.CurrentPaperSource = e1.PaperSources[2];
                }
                //Set the paper source of the rest of pages as tray 2
                else
                {
                    e1.CurrentPaperSource = e1.PaperSources[1];
                }
            };
            this.pdfDocumentViewer1.Print();

Sincerely,
Kylie
E-iceblue support team
User avatar

kylie.tian
 
Posts: 412
Joined: Mon Mar 07, 2022 2:30 am

Wed May 11, 2022 9:19 am

Hi
I did not tried your solution yet, but before that, It is not clear for me what do you mean by: Set the paper source of page 1-2 as tray 1?
As I understand If I have 7 pages, the først 2 pages will be print out from Tray 1 And the rest of 5 pages from Tray 2. Is it Correct? If yes, then I can not use it to solve the problem.

Thank you
Best regards
Hossein

hossein9
 
Posts: 4
Joined: Mon Apr 28, 2014 5:12 pm

Wed May 11, 2022 10:41 am

Hi,

Yes, the code I provided is to select different tray and print pages. Could you please provide more descriptions to clarify your requirement? That's will be helpful.

Sincerely,
Kylie
E-iceblue support team
User avatar

kylie.tian
 
Posts: 412
Joined: Mon Mar 07, 2022 2:30 am

Thu May 12, 2022 10:25 am

Hi
Users needs to print from tray 4 where there is speciel paper. So this solution is not useable.
General there is problem by printing function, it is too slow. I used the free version, and it worked fine, but when I bought the new version, almost nothing works.
The function to compress images can not resize the volumn of file.
That is why I have to remove the spire component.
thank you
Best regards
Hossein

hossein9
 
Posts: 4
Joined: Mon Apr 28, 2014 5:12 pm

Fri May 13, 2022 11:03 am

Hi Hossein,

Sorry, I don't quite understand why we can't use "e1.CurrentPaperSource = e1.PaperSources[4];" to achieve the desired purpose? Will this have any other effects?
Regarding the slow printing speed, could you provide a sample document and how long it takes to print on your side?
Finally, could you please elaborate on the issue of compressing images? It would be better if you provided your test code along with the PDF document. You can share the information here or sent it to us via email(support@e-iceblue.com).
Thanks in advance for your assistance.
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Return to Spire.DocViewer

cron