thanvanhai
(Thân Văn Hải)
1
I want to use ExportToDisk method to PDF file from Ice.Lib.Report.EpiCrystalViewer library?
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
private void CreatePO_FilePDF(string reportfile,DataTable tmp)
{
try{
session= (Session)this.oTrans.Session;
//string invoicenum="";
string PathRoot=@"\\"+session.AppServer.Split('/')[2].Split(':')[0];
/* if(txtListInv.Text=="")
{
EpiDataView view = oTrans.EpiDataViews["InvcHead"] as EpiDataView;
invoicenum = view.dataView[view.Row]["InvoiceNum"].ToString()+"~";
}
else
{
invoicenum=txtListInv.Text.Replace(",","~")+"~";
} */
string Key_link11="";
string Key_link12="";
Key_link11=GetBAQUD05("SelectUD05","ReportData").Item2;
Key_link12=GetBAQUD05("SelectUD05","ReportDirectory").Item2;
string strPat=@"\\"+session.AppServer.Split('/')[2].Split(':')[0];
string PathXml=Key_link11+"\\"+((Session)this.oTrans.Session).UserID+"\\POSendMaill.XML";
string PathDesRpt=Key_link11+"\\"+((Session)this.oTrans.Session).UserID+"\\" +reportfile;
string PathRpt=Key_link12+"\\"+reportfile;
File.Copy(PathRpt,PathDesRpt, true);//thêm biến true cho phép overwrite tránh xảy ra lỗi phải vào xóa file khi tắt màn hình in mà chưa xóa file
tmp.WriteXml(PathXml,XmlWriteMode.WriteSchema);
Ice.Lib.Report.EpiCrystalViewer report = new Ice.Lib.Report.EpiCrystalViewer(PathDesRpt, PathXml,"PO Send Maill");
report.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, @"D:\ASD.pdf");
report.ShowDialog();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}

Thank you so much have a nice day! 
I haven’t tried this, but here is some example code:
1 Like
thanvanhai
(Thân Văn Hải)
3
thank you i made it
use ReportDocument to load Epicor’s Ice.Lib.Report.EpiCrystalViewer and then export the file from ReportDocument
private void PrintOrCreatePO_FilePDF(string reportfile,DataTable tmp, string namePDF, int print)
{
try{
session= (Session)this.oTrans.Session;
//string invoicenum="";
string PathRoot=@"\\"+session.AppServer.Split('/')[2].Split(':')[0];
/* if(txtListInv.Text=="")
{
EpiDataView view = oTrans.EpiDataViews["InvcHead"] as EpiDataView;
invoicenum = view.dataView[view.Row]["InvoiceNum"].ToString()+"~";
}
else
{
invoicenum=txtListInv.Text.Replace(",","~")+"~";
} */
string Key_link11="";
string Key_link12="";
Key_link11=GetBAQUD05("SelectUD05","ReportData").Item2;
Key_link12=GetBAQUD05("SelectUD05","ReportDirectory").Item2;
string strPat=@"\\"+session.AppServer.Split('/')[2].Split(':')[0];
string PathXml=Key_link11+"\\"+((Session)this.oTrans.Session).UserID+"\\POSendMaill.XML";
string PathDesRpt=Key_link11+"\\"+((Session)this.oTrans.Session).UserID+"\\" +reportfile;
string PathRpt=Key_link12+"\\"+reportfile;
File.Copy(PathRpt,PathDesRpt, true);//thêm biến true cho phép overwrite tránh xảy ra lỗi phải vào xóa file khi tắt màn hình in mà chưa xóa file
tmp.WriteXml(PathXml,XmlWriteMode.WriteSchema);
Ice.Lib.Report.EpiCrystalViewer report = new Ice.Lib.Report.EpiCrystalViewer(PathDesRpt, PathXml,"PO Send Maill");
ReportDocument cryRpt = new ReportDocument();
cryRpt.Load(PathDesRpt);
//crystalReportViewer1.ReportSource = cryRpt;
//crystalReportViewer1.Refresh();
if (print ==0)//Review report
report.ShowDialog();
else if (print ==1)//xuất file PDF để gửi maill
{
string PathAndNamePDFFile = Key_link11+"\\"+((Session)this.oTrans.Session).UserID+"\\"+namePDF;
cryRpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, PathAndNamePDFFile);
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Have a good day! 