printing html file without printdialog show up
-
Hi there, Is there anyway that I can print the html file from commandline without showing print dialog? I tried ShellExecuteEx and it does nothing. Thank you.
Have you looked at PrintDocument? ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETDEVFX.v20.en/cpref8/html/T_System_Drawing_Printing_PrintDocument.htm Example:
class Program { static Font printFont = new Font("Arial", 10); static void Main(string[] args) { PrintDocument doc = new PrintDocument(); doc.PrintPage += new PrintPageEventHandler(doc_PrintPage); doc.Print(); } static void doc_PrintPage(object sender, PrintPageEventArgs e) { float leftMargin = e.MarginBounds.Left; float topMargin = e.MarginBounds.Top; float yPos = topMargin + (printFont.GetHeight(e.Graphics)); // In the line below, 'Hello' would be replaced with the next line from // whatever you were trying to print. // It's actually a little more involved, but not terrible. e.Graphics.DrawString("Hello", printFont, Brushes.Black, leftMargin, yPos, new StringFormat()); e.HasMorePages = false; } }
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’