コード例 #1
0
        private void FormPrintPreview_Load(object sender, System.EventArgs e)
        {
            LayoutToolBar();
            PrintDocument printdoc = Document; //Default to the old printing pattern.

            if (_printout == null)             //Old print pattern.
            //Try to find the printable area.  If there are no printers, it will throw an InvalidPrinterException
            {
                if (PrinterSettings.InstalledPrinters.Count == 0)
                {
                    MsgBox.Show(this, "Error: No Printers Installed\r\n" +
                                "If you do have a printer installed, restarting the workstation may solve the problem."
                                );
                    DialogResult = DialogResult.Cancel;
                    return;
                }
                if (printdoc.DefaultPageSettings.PrintableArea.Height == 0)
                {
                    printdoc.DefaultPageSettings.PaperSize = new PaperSize("default", 850, 1100);
                }
            }
            else              //New print pattern
            {
                if (_printout.SettingsErrorCode != PrintoutErrorCode.Success)
                {
                    PrinterL.ShowError(_printout);
                    DialogResult = DialogResult.Cancel;
                    return;
                }
                printdoc = _printout.PrintDoc;
            }
            LoadPrintDocument(printdoc);
            SetPageNumText();
        }
コード例 #2
0
 ///<summary></summary>
 private void PrintReport()
 {
     try{
         if (PrinterL.SetPrinter(pd2, PrintSituation.Default))
         {
             pd2.Print();
         }
     }
     catch {
         MessageBox.Show(Lan.g(this, "Printer not available"));
     }
 }
コード例 #3
0
ファイル: PrintPreview.cs プロジェクト: kjb7749/testImport
 private void OnPrint_Click()
 {
     if (!PrinterL.SetPrinter(Document, Sit))
     {
         return;
     }
     if (Document.OriginAtMargins)
     {
         //In the sheets framework,we had to set margins to 20 because of a bug in their preview control.
         //We now need to set it back to 0 for the actual printing.
         //Hopefully, this doesn't break anything else.
         Document.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0);
     }
     try{
         Document.Print();
     }
     catch (Exception e) {
         MessageBox.Show(Lan.g(this, "Error: ") + e.Message);
     }
     DialogResult = DialogResult.OK;
 }