2013-08-17 58 views
-1

最近我有一个项目教育管理系统是在Windows应用程序中使用C#.net在我使用打印文档控制打印标记工作表布局和它的工作好..但我必须在Asp.net网站上进行转换因此,任何打印方法打印标记工作表布局与打印文档和标记内容相同的质量工作表从数据库抓取。 任何代码都可以帮助您在C#中完全打印Java脚本。有关打印,但打印质量的任何代码是必要的,因为标记页打印用C#打印Asp.Net

我有代码的窗口appilcation相关的代码,但我想基于Web的解决方案

private void printDocument2_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) 
    { 
     e.Graphics.DrawRectangle(Pens.Black, rectangleShape1.Location.X, rectangleShape1.Location.Y, rectangleShape1.Width, rectangleShape1.Height); 
     ////////////////////////////// 
     e.Graphics.DrawString(label24.Text, label24.Font, Brushes.DarkBlue, label24.Location.X, label24.Location.Y); 
     e.Graphics.DrawString(label25.Text, label25.Font, Brushes.DarkBlue, label25.Location.X, label25.Location.Y); 
     e.Graphics.DrawString(label26.Text, label26.Font, Brushes.Brown, label26.Location.X, label26.Location.Y); 
     e.Graphics.DrawString(label27.Text, label27.Font, Brushes.Black , label27.Location.X, label27.Location.Y); 
     e.Graphics.DrawString(label28.Text, label28.Font, Brushes.Black, label28.Location.X, label28.Location.Y); 
     e.Graphics.DrawString(label29.Text, label29.Font, Brushes.Black, label29.Location.X, label29.Location.Y); 
     e.Graphics.DrawString(label30.Text, label30.Font, Brushes.Black, label30.Location.X, label30.Location.Y); 
     e.Graphics.DrawString(label31.Text, label31.Font, Brushes.Black, label31.Location.X, label31.Location.Y); 
     //////////////////////////// 
     e.Graphics.DrawString(txtRollno.Text, txtRollno.Font, Brushes.Black, txtRollno.Location.X, txtRollno.Location.Y); 
     e.Graphics.DrawString(txtName.Text, txtName.Font, Brushes.Black, txtName.Location.X, txtName.Location.Y); 
     e.Graphics.DrawString(txtfathernameid.Text, txtfathernameid.Font, Brushes.Black, txtfathernameid.Location.X, txtfathernameid.Location.Y); 
     e.Graphics.DrawString(txtAddress.Text, txtAddress.Font, Brushes.Black, txtAddress.Location.X, txtAddress.Location.Y); 
     e.Graphics.DrawString(txtContact.Text, txtContact.Font, Brushes.Black, txtContact.Location.X, txtContact.Location.Y); 
    //////////////// 
     e.Graphics.DrawImage(pictureBox1.Image, pictureBox1.Location.X, pictureBox1.Location.Y, pictureBox1.Width, pictureBox1.Height); 
    } 


private void btnPrintPreview2_Click(object sender, EventArgs e) 
    { 
     printPreviewDialog1.Document = printDocument2; 
     printPreviewDialog1.Show Dialog(); 
    } 

回答

2

没有在ASP.Net提供像控制在.Net的Window版本中。可能的方法是首先将报告/文档呈现为PDF/Word或XLS,然后打印。有很多开源项目可以随时创建PDF/XLS文件,我最喜欢的是http://pdfsharp.com/,最近在PDFsharp lib之上,他们添加了MigraDoc库,这对创建PDF文档和打印它们非常有帮助。

+0

感谢您的答复,但我听比我们还可以通过Java脚本打印的HTML页面,以便打印任何Java代码,纸条是 –

+0

你可以打印HTML,它很简单,只需调用window.print(),http://www.w3schools.com/jsref/met_win_print.asp。为了获得更好的效果,您可能需要为打印介质创建一个单独的CSS样式表。 –

1

要打印在JavaScript中你使用的页面:

window.print(); 
+0

感谢您的回复,但我已经使用过。 –