Click here to Skip to main content
15,919,121 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have code like this.....
C#
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 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...
Posted
Updated 29-Dec-14 23:19pm
v2

1 solution

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....
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900