C Printdialog Print From File Html

[Solved] C Printdialog Print From File Html | Vb - Code Explorer | yomemimo.com
Question : c# PrintDialog Print from file html

Answered by : ghoulam-mehdi

[code] Process printJob = new Process(); printJob.StartInfo.FileName = localReportPath + filename + ".html"; printJob.StartInfo.UseShellExecute = true; printJob.StartInfo.Verb = "printto"; printJob.StartInfo.CreateNoWindow = true; printJob.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; printJob.StartInfo.Arguments = string.Format("{0} {1}", "Microsoft XPS Document Writer", "xx"); //printJob.StartInfo.Arguments = "\"" + printerAddress + "\"" + " " + "Microsoft XPS Document Writer"; printJob.StartInfo.WorkingDirectory = Path.GetDirectoryName(localReportPath + filename + ".html"); printJob.Start();
[/code]

Source : https://social.msdn.microsoft.com/Forums/en-US/56257304-16a9-4132-ba85-c8102c70ee46/printing-a-html-file-on-server-side-using-c?forum=wcf | Last Update : Fri, 11 Nov 22

Question : c# PrintDialog Print from file html

Answered by : ghoulam-mehdi

[code] StreamReader streamToPrint; public void printdoc(string doc1) { using (PrintDocument doc = new PrintDocument()) { streamToPrint = new StreamReader(doc1); ///doc.PrintPage += this.html_PrintPage; doc.DocumentName = "Hello"; doc.DefaultPageSettings.Landscape = false; doc.PrintPage += new PrintPageEventHandler(doc_PrintPage); doc.PrinterSettings.PrinterName = "Microsoft XPS Document Writer"; doc.PrintController = new StandardPrintController(); doc.PrinterSettings.PrintFileName = doc1; doc.Print(); } //PrintDocument doc = new PrintDocument(); //doc.PrintController = new StandardPrintController(); //doc.PrintPage += new PrintPageEventHandler(doc_PrintPage); //doc.Print(); } public void doc_PrintPage(object sender, PrintPageEventArgs ev) { Font printFont = new Font(FontFamily.GenericSerif, 12); 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); // Print each line of the file. 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; }
[/code]

Source : https://social.msdn.microsoft.com/Forums/en-US/56257304-16a9-4132-ba85-c8102c70ee46/printing-a-html-file-on-server-side-using-c?forum=wcf | Last Update : Fri, 11 Nov 22

Answers related to c printdialog print from file html

Code Explorer Popular Question For Vb