2010-06-06 3 views
1

Crystal 보고서를 사용하여 보고서를 작성했습니다. 개발 중에는 모든 것이 정상입니다.
웹 사이트를 배포 한 후에 인쇄 기능이 작동하지 않습니다.배포 후 Crystal Report 인쇄 기능이 작동하지 않습니까?

_rptDocument.PrintToPrinter (1, false, 0, 0);를 사용합니다. 보고서를 인쇄합니다.

나는 웹 사이트를

  1. 게시 일반 옵션을 배포하는 두 가지 방법을 시도했습니다.
  2. 웹 배포 프로젝트.

출력이 같지만 인쇄 기능이 작동하지 않습니다.
또한 기본 프린터를 설정하려고 시도했으나 작동하지 않습니다.

아이디어가 있으십니까?

답변

2

웹 서버에서 인쇄하는 것은 좋은 생각이 아닙니다. 어떻게해야합니까? 사용자가 서버 프린터에서 인쇄합니까? CR을 사용하여 PDF를 작성하십시오. 고객에게 스트리밍하십시오. 그들은 로컬 프린터를 사용할 수 있습니다.

+0

CR은 클라이언트의 로컬 PC에서 인쇄합니다. – Ahmed

+0

Ok - 인쇄 대신 PDF 생성 기능을 사용하는 것이 현명합니다. 귀하의 코드는 서버 측 (ASP.NET)입니다. 서버의 클라이언트 인쇄 환경에 대한 지식은 없습니다. –

+0

+1, PDF 생성은 내가이 상황에서 사용할 것입니다. –

1

이 시도 : - PDF 및 오픈 브라우저 탭을 만들기 ... enter code here

string fname = "Report" + ".pdf";`enter code here` 
     //Create instance for crystal report Export option class 
     ExportOptions exprtopt = default(ExportOptions); 

     //create instance for destination option - This one is used to set path of your pdf file save 
     DiskFileDestinationOptions destiopt = new DiskFileDestinationOptions(); 

     //Bind data in the crystal report first before export cystal report to PDF 
     ReportDocument RptDoc = new ReportDocument(); 

     //Map your crystal report path 
     // RD.Load(Server.MapPath("~/CrystalReport2.rpt")); 

     //Set your crystal report datasource as dt 


     //Get path and assign into destination DiskFileName 
     destiopt.DiskFileName = Server.MapPath(fname); 

     exprtopt = RD.ExportOptions; 
     exprtopt.ExportDestinationType = ExportDestinationType.DiskFile; 

     //use PortableDocFormat for PDF data 
     exprtopt.ExportFormatType = ExportFormatType.PortableDocFormat; 
     exprtopt.DestinationOptions = destiopt; 

     //finally export your report document 
     RD.Export(); 

     //To open your PDF after save it from crystal report 

     string Path = Server.MapPath(fname); 

     //create instance to client to open your pdf 
     WebClient client = new WebClient(); 

     //Assign path to download pdf 
     Byte[] buffer = client.DownloadData(Path); 

     //metion content type as PDF and write 
     // Response.ContentType = "application/pdf"; 
     //Response.AddHeader("content-length", buffer.Length.ToString()); 
     //Response.BinaryWrite(buffer); 

     //====================================== 
     Response.Write("<script>"); 
     Response.Write("window.open('" + fname + "', '_newtab');"); 
     Response.Write("</script>"); 
     //=================================== 

IMTIYAZ