Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- browser.Print();
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Drawing.Printing;
- using System.Runtime.InteropServices;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- foreach (var item in PrinterSettings.InstalledPrinters)
- {
- Console.WriteLine(item.ToString());
- }
- string pname = "Nuance PDF";
- myPrinters.SetDefaultPrinter(pname);
- PrintHelpPage();
- Console.ReadKey();
- }
- public static class myPrinters
- {
- [DllImport("winspool.drv", CharSet = CharSet.Auto, SetLastError = true)]
- public static extern bool SetDefaultPrinter(string Name);
- }
- public static void PrintHelpPage()
- {
- var th = new Thread(() => {
- var br = new WebBrowser();
- br.DocumentCompleted += PrintDocument;
- br.Navigate("http://oneguggenheim/compliance/Pages/EAA/EAAConsolidatedForm.aspx?AttestationTaskID=65033");
- Application.Run();
- });
- th.SetApartmentState(ApartmentState.STA);
- th.Start();
- }
- public static void PrintDocument(object sender,
- WebBrowserDocumentCompletedEventArgs e)
- {
- var browser = sender as WebBrowser;
- // Print the document now that it is fully loaded.
- browser.Print();
- Console.WriteLine("Natigated to {0}", e.Url);
- // Dispose the WebBrowser now that the task is complete.
- browser.Dispose();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement