WEB水晶报表打印问题?????????????
本人现在使用水晶报表9,想实现WEB下打印功能:
下面是函数,可是在寻找打印机上有问题:请问有没有好的解决方法:
private void btnPrint_Click(object sender, System.EventArgs e)
{
printerName=this.ddlPrint.SelectedItem.Text.ToString().Trim();//打印机名称
string sql="select * from OR_PR_O where PRNM='"+printerName+"'";//获取打印机路径
DataSet ds=conn.CreateDataSet(sql,"OR_PR_O");
string strPrinterName = @"\\"+ds.Tables[0].Rows[0]["PS"].ToString().Trim()+"\\"+printerName;//路径和名称
// if (printDoc.PrinterSettings.IsValid)
// {
// string sqlset="select * from XTCS_SET";
// ds=conn.CreateDataSet(sqlset,"XTCS_SET");
// if(ds.Tables[0].Rows[0]["ISCOLOR"].ToString().Trim()=="1")
// {
// printDoc.DefaultPageSettings.Color=true;
// }
// else
// {
// printDoc.DefaultPageSettings.Color=false;
// }
// (Server.MapPath("/DamSurvey")+"\\DataAdmin\\picture\\picture\\"+ImgFileName);
// filePath=Server.MapPath("../Report/Inter_TPPipe_TCTable.rpt");
// streamToPrint=new StreamReader(filePath);
// streamToPrint=new StreamReader("e:\\DamSurvey\\DataAdmin\\Report\\RPT\\Inter_TPPipe_TCTable.rpt");
// int leftMargins=System.Convert.ToInt32(ds.Tables[0].Rows[0]["RPTLEFT"].ToString().Trim());
// int topMargins=System.Convert.ToInt32(ds.Tables[0].Rows[0]["RPTTOP"].ToString().Trim());
// Margins margins = new Margins(100,100,100,100);
// printDoc.DefaultPageSettings.Margins=margins;
// printDoc.DefaultPageSettings.PaperSize=;
// string fontType=ds.Tables[0].Rows[0]["RPTFONT"].ToString().Trim();
string filePath=Server.MapPath("../Report/Inter_TPPipe_TCTable.rpt");
filePath=Server.MapPath("/DamSurvey")+"\\DataAdmin\\Report\\RPT\\Inter_TPPipe_TCTable.rpt";
printFont = new Font("Arial",10);
streamToPrint=new StreamReader(filePath);
printDoc.PrinterSettings.PrinterName="5D PDF Creator";
printDoc.PrintPage +=new PrintPageEventHandler(this.printDoc_PrintPage);
printDoc.DefaultPageSettings.Landscape=true;//横向打印
printDoc.Print();
// }
// else
// {
// Response.Write("<script>alert('打印机无效!');</script>");
// }
}
private void ddlPrint_SelectedIndexChanged(object sender, System.EventArgs e)
{
printerName=this.ddlPrint.SelectedItem.Text.ToString().Trim();//更改打印机名称
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="ev"></param>
private void printDoc_PrintPage(object sender, PrintPageEventArgs ev)
{
float linesPerPage = 0;
float yPos = 0;
int count = 0;
float leftMargin = ev.MarginBounds.Left;
float topMargin = ev.MarginBounds.Top;
String line=null;
// Calculate the number of lines per page.
linesPerPage = ev.MarginBounds.Height/printFont.GetHeight(ev.Graphics) ;
// Iterate over the file, printing each line.
while (count < linesPerPage && ((line=streamToPrint.ReadLine()) != null))
{
yPos = topMargin + (count * printFont.GetHeight(ev.Graphics));
ev.Graphics.DrawString (line, printFont, Brushes.Black,leftMargin, yPos, new StringFormat());
count++;
}
// If more lines exist, print another page.
if (line != null)
ev.HasMorePages = true;
else
ev.HasMorePages = false;
}
}
下面是函数,可是在寻找打印机上有问题:请问有没有好的解决方法:
private void btnPrint_Click(object sender, System.EventArgs e)
{
printerName=this.ddlPrint.SelectedItem.Text.ToString().Trim();//打印机名称
string sql="select * from OR_PR_O where PRNM='"+printerName+"'";//获取打印机路径
DataSet ds=conn.CreateDataSet(sql,"OR_PR_O");
string strPrinterName = @"\\"+ds.Tables[0].Rows[0]["PS"].ToString().Trim()+"\\"+printerName;//路径和名称
// if (printDoc.PrinterSettings.IsValid)
// {
// string sqlset="select * from XTCS_SET";
// ds=conn.CreateDataSet(sqlset,"XTCS_SET");
// if(ds.Tables[0].Rows[0]["ISCOLOR"].ToString().Trim()=="1")
// {
// printDoc.DefaultPageSettings.Color=true;
// }
// else
// {
// printDoc.DefaultPageSettings.Color=false;
// }
// (Server.MapPath("/DamSurvey")+"\\DataAdmin\\picture\\picture\\"+ImgFileName);
// filePath=Server.MapPath("../Report/Inter_TPPipe_TCTable.rpt");
// streamToPrint=new StreamReader(filePath);
// streamToPrint=new StreamReader("e:\\DamSurvey\\DataAdmin\\Report\\RPT\\Inter_TPPipe_TCTable.rpt");
// int leftMargins=System.Convert.ToInt32(ds.Tables[0].Rows[0]["RPTLEFT"].ToString().Trim());
// int topMargins=System.Convert.ToInt32(ds.Tables[0].Rows[0]["RPTTOP"].ToString().Trim());
// Margins margins = new Margins(100,100,100,100);
// printDoc.DefaultPageSettings.Margins=margins;
// printDoc.DefaultPageSettings.PaperSize=;
// string fontType=ds.Tables[0].Rows[0]["RPTFONT"].ToString().Trim();
string filePath=Server.MapPath("../Report/Inter_TPPipe_TCTable.rpt");
filePath=Server.MapPath("/DamSurvey")+"\\DataAdmin\\Report\\RPT\\Inter_TPPipe_TCTable.rpt";
printFont = new Font("Arial",10);
streamToPrint=new StreamReader(filePath);
printDoc.PrinterSettings.PrinterName="5D PDF Creator";
printDoc.PrintPage +=new PrintPageEventHandler(this.printDoc_PrintPage);
printDoc.DefaultPageSettings.Landscape=true;//横向打印
printDoc.Print();
// }
// else
// {
// Response.Write("<script>alert('打印机无效!');</script>");
// }
}
private void ddlPrint_SelectedIndexChanged(object sender, System.EventArgs e)
{
printerName=this.ddlPrint.SelectedItem.Text.ToString().Trim();//更改打印机名称
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="ev"></param>
private void printDoc_PrintPage(object sender, PrintPageEventArgs ev)
{
float linesPerPage = 0;
float yPos = 0;
int count = 0;
float leftMargin = ev.MarginBounds.Left;
float topMargin = ev.MarginBounds.Top;
String line=null;
// Calculate the number of lines per page.
linesPerPage = ev.MarginBounds.Height/printFont.GetHeight(ev.Graphics) ;
// Iterate over the file, printing each line.
while (count < linesPerPage && ((line=streamToPrint.ReadLine()) != null))
{
yPos = topMargin + (count * printFont.GetHeight(ev.Graphics));
ev.Graphics.DrawString (line, printFont, Brushes.Black,leftMargin, yPos, new StringFormat());
count++;
}
// If more lines exist, print another page.
if (line != null)
ev.HasMorePages = true;
else
ev.HasMorePages = false;
}
}
...全文
相关推荐
水晶报表ActiveX 打印(web打印)解决方法
水晶报表ActiveX 打印(web打印) 解决方法 解决控件无法安装, 安装控件也没卡死 部署到到服务器打印一闪而过。
水晶报表ActiveX Web打印问题及解决策略
水晶报表(Crystal Reports)是业界广泛使用的一种报表设计工具,其ActiveX控件版本被集成到网页中以实现报表的打印功能。使用此控件,开发者能够将报表嵌入到Web应用程序中,允许终端用户通过浏览器打印报表。然而,随着Web技术的不断进步,ActiveX控件的技术局限性和安全问题越来越成为企业和开发者的挑战。ActiveX控件是一种由微软公司开发的组件对象模型(COM)技术,它允许在支持ActiveX的网页中嵌入可执行的组件。
水晶报表java web实现
自己书写的java web的报表实现,tomcat启动后,url输入http://localhost:8080/tmpidsm/bo就可以了,
winform 水晶报表打印,无预览
winform 水晶报表打印,无预览 。USB 热敏打印机。
水晶报表自定义纸张大小打印
水晶报表查看器CrystalReportViewer自带打印功能,调用当前系统默认打印机进行打印,但.NET里的水晶版本不支持Web打印,需要水晶报表10以上的版本才支持。另外由于其他原因,我们大多需要自己写代码进行打印,这就牵扯到如何写代码、如何设置打印参数的 问题,以下是一些基本知识:


图表区
