請問如何讓我的水晶報表保存我的自定義紙張的設定。

解决方案 »

  1.   

    代碼始下:結果是預覽沒問題,但是打印機設定中不是我的自定義紙張大小PrinterSettings ps = new PrinterSettings();
                 PrintPreview pp = new PrintPreview();
                 Form w = new waiting();
                 try
                 {
                     w.Show();
                     DataSet DSXHDP = new DataSet();
                     byte[] b = POS.Report_XHD_print(XHDH);
                     DSXHDP = BASEINFO.DecompressDS(b);
                     DSXHDP.Tables[0].TableName = "Command";
                     REPORT.XHprint xhPRINT = new POS.REPORT.XHprint();
                     if (ps.IsValid && ps.IsDefaultPrinter)
                     {
                         int i = -1;
                         foreach (PaperSize pas in ps.PaperSizes)
                         {
                             if (pas.PaperName == "XH_P")
                             {
                                 i = pas.RawKind;
                                 break;
                             }
                         }
                         if (i == -1)//如果沒有找到自定義紙張,添加自定義紙張
                         {
                             SetPaperSize("XH_P", 1200, 1800);
                             foreach (PaperSize pas in ps.PaperSizes)
                             {
                                 if (pas.PaperName == "XH_P")
                                 {
                                     i = pas.RawKind;
                                     break;
                                 }
                             }
                         }
                         pp.crystalReportViewer1.ReportSource = xhPRINT;
                         
                         xhPRINT.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize)i;
                     }
                    // pp.crystalReportViewer1.ReportSource = xhPRINT;
                     xhPRINT.SetDataSource(DSXHDP.Tables[0]);
                     xhPRINT.SetParameterValue("FKJE", SS);
                     xhPRINT.SetParameterValue("ZHJE", ZH);
                     xhPRINT.SetParameterValue("GKXM", "");
                     xhPRINT.SetParameterValue("GTBHMC", "");
                   
                     pp.Show();
                     //xhPRINT.PrintToPrinter(1, false, 0, 0);//直接送到打印機
                 }
                  catch
                  {
                  MessageBox.Show("打印補中斷,請檢查印表機");
                 }
                 finally
                 {
                     w.Close();
                 }
    }
      

  2.   

    難道是驅動的問題?我打打印機是新式的,驅動通通用epson lq_1000的,難道是這個原因?