ds_Leader.Tables.Add(dt); ds_Leader.Tables[0].TableName = "dt";// ds_Leader.Tables.Add(dt1); ds_Leader.Tables[1].TableName = "dt1";// //ReportDocument rtd = new ReportDocument(); //string path = Server.MapPath("\\QueryStatistic\\CrystalReport\\ReserveSummaryReport.rpt"); //rtd.Load(path); //rtd.SetDataSource(ds_Leader); //CrystalReportViewer1.ReportSource = rtd; CommonOper.PDFOperate pdfOperate = new CommonOper.PDFOperate(); CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new ReportDocument(); rptDoc.Load(this.Server.MapPath("\\QueryStatistic\\CrystalReport\\ReserveSummaryReport.rpt")); rptDoc.SetDataSource(ds_Leader); CrystalDecisions.Shared.DiskFileDestinationOptions objFile = new CrystalDecisions.Shared.DiskFileDestinationOptions(); objFile.DiskFileName = this.Server.MapPath("myTest.pdf"); rptDoc.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; rptDoc.ExportOptions.DestinationOptions = objFile; rptDoc.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat; rptDoc.Export(); string error = "pdf生成水印错误"; bool IsRight = pdfOperate.AddTextWaterMark("myTest.pdf", ref error, DateTime.Now.ToString(), 0); Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "application/pdf"; Response.WriteFile(objFile.DiskFileName); Response.Flush(); Response.Close();