请教asp.net下的打印问题.
比如利用JavaScript实现打印,利用WebBrowser实现打印,这些就算了,我不想要这些.我现在都是在导出到EXCEL表里面然后打印.
如果用报表是可以实现这些的,但是我对报表不是很熟悉,加上排版美观,也比较的麻烦,这个方法也算了.
我现在想问的就是有没有什么方法.直接可以打印的.比如我用FormView生成一个表单,然后怎么可以与打印机连接,,然后打印出来.不知道有没有哪位高手做过这方面的功能! --------------------编程问答-------------------- 你如果不借助其他控件或产品。就只能用浏览器的print方法了。Formview生成完了不还是要到前台,在浏览器里打印嘛。 --------------------编程问答-------------------- 不懂,帮顶 --------------------编程问答-------------------- UP.UP.UP --------------------编程问答-------------------- MSDN上的:
--------------------编程问答-------------------- 看看! --------------------编程问答-------------------- 留名 学习
[C#]
public class PrintingExample
{
private Font printFont;
private StreamReader streamToPrint;
static string filePath;
public PrintingExample()
{
Printing();
}
// The PrintPage event is raised for each page to be printed.
private void pd_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;
}
// Print the file.
public void Printing()
{
try
{
streamToPrint = new StreamReader (filePath);
try
{
printFont = new Font("Arial", 10);
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
// Print the document.
pd.Print();
}
finally
{
streamToPrint.Close() ;
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
// This is the main entry point for the application.
public static void Main(string[] args)
{
string sampleName = Environment.GetCommandLineArgs()[0];
if(args.Length != 1)
{
Console.WriteLine("Usage: " + sampleName +" <file path>");
return;
}
filePath = args[0];
new PrintingExample();
}
}
补充:.NET技术 , ASP.NET