直接打印pdf文件而无需在c#中打开打印dilogbox [英] printing a pdf file Directly without opening print dilogbox in c#
本文介绍了直接打印pdf文件而无需在c#中打开打印dilogbox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这样的代码.....
i have code like this.....
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=VisitosFoodBill_BillNo-" + Tranid + ".pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter stringWriter = new StringWriter();
HtmlTextWriter htmlTextWriter = new HtmlTextWriter(stringWriter);
print.RenderControl(htmlTextWriter);
StringReader stringReader = new StringReader(stringWriter.ToString());
Document Doc = new Document(new RectangleReadOnly(550, (i*20)+480), 10f, 10f, 10f, 10f);
HTMLWorker htmlparser = new HTMLWorker(Doc);
PdfWriter.GetInstance(Doc, Response.OutputStream);
Doc.Open();
htmlparser.Parse(stringReader);
Doc.Close();
Response.Write(Doc);
Response.End();
.............
i希望添加更多代码直接打印pdf文件没有打开打印dilogbox。
我怎么不知道请帮我,我写的是什么代码来打印pdf文件的过程..
谢谢...
.............
i want to add more code to print pdf file Directly without opening print dilogbox.
how i don't know please help me that what code i write to do the process of printing pdf file..
thanks...
推荐答案
不知道你是否需要在客户端打印.....好试试这个
ProcessStartInfo info = new ProcessStartInfo();
info.Verb =print;
info.FileName = @c:\\\ output.pdf;
info.CreateNoWindow = true;
info.WindowStyle = ProcessWindowStyle.Hidden;
流程p =新流程();
p.StartInfo = info;
p.Start();
p.WaitForInputIdle();
System.Threading.Thread.Sleep(3000);
if(false == p。 CloseMainWindow())
p.Kill();
在http://stackoverflow.com/questions/17448465/send-pdf-file-to-a-printer-print-pdf
上找到了这个b $ b
希望,这有助于....
dont know if you have to print on client.....well try this
ProcessStartInfo info = new ProcessStartInfo();
info.Verb = "print";
info.FileName = @"c:\output.pdf";
info.CreateNoWindow = true;
info.WindowStyle = ProcessWindowStyle.Hidden;
Process p = new Process();
p.StartInfo = info;
p.Start();
p.WaitForInputIdle();
System.Threading.Thread.Sleep(3000);
if (false == p.CloseMainWindow())
p.Kill();
found this on http://stackoverflow.com/questions/17448465/send-pdf-file-to-a-printer-print-pdf
hope, this helps....
这篇关于直接打印pdf文件而无需在c#中打开打印dilogbox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文