Example #1
0
        private void Print_Click()
        {
            PrintDocument pd = new PrintDocument();

            pd.DocumentName                  = viewer.SourceFile;
            pd.PrinterSettings.FromPage      = 1;
            pd.PrinterSettings.ToPage        = viewer.PageCount;
            pd.PrinterSettings.MaximumPage   = viewer.PageCount;
            pd.PrinterSettings.MinimumPage   = 1;
            pd.DefaultPageSettings.Landscape = viewer.PageWidth > viewer.PageHeight;
            pd.DefaultPageSettings.Margins   = new Margins(50, 50, 50, 50);     //Half-inch all around.
            //This prevents a bug caused by some printer drivers not reporting their papersize.
            //But remember that other countries use A4 paper instead of 8 1/2 x 11.
            if (pd.DefaultPageSettings.PrintableArea.Height == 0)
            {
                pd.DefaultPageSettings.PaperSize = new PaperSize("default", 850, 1100);
            }
            try{
                if (PrinterL.SetPrinter(pd, PrintSituation.Default))
                {
                    if (pd.PrinterSettings.PrintRange == PrintRange.Selection)
                    {
                        pd.PrinterSettings.FromPage = viewer.PageCurrent;
                    }
                    viewer.Print(pd);
                }
            }
            catch {
                MessageBox.Show(Lan.g(this, "Printer not available"));
            }
        }
Example #2
0
		private void Print_Click(){
			PrintDocument pd=new PrintDocument();
			pd.DocumentName=viewer.SourceFile;
			pd.PrinterSettings.FromPage=1;
			pd.PrinterSettings.ToPage=viewer.PageCount;
			pd.PrinterSettings.MaximumPage=viewer.PageCount;
			pd.PrinterSettings.MinimumPage=1;
			pd.DefaultPageSettings.Landscape=viewer.PageWidth>viewer.PageHeight;
			try{
				if(Printers.SetPrinter(pd,PrintSituation.Default)){
					if(pd.PrinterSettings.PrintRange==PrintRange.Selection) {
						pd.PrinterSettings.FromPage=viewer.PageCurrent;
					}
					viewer.Print(pd);
				}
			}
			catch{
				MessageBox.Show(Lan.g(this,"Printer not available"));
			}
		}