My default printer is set to "nuance pdf" which saves files to pdf. I have console application that uses webBrowser.Print(). This command by-passes print pop up and brings up "Save As" page:
I want to pro-grammatically enter filename and save the file, without seeing this pop up. How do I achieve this? Any suggestions/pointers?
This is the code which I took from: C# : "How to use WebBrowser and print the html to the console. "
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
PrintHelpPage();
Console.ReadKey();
}
public static void PrintHelpPage()
{
var th = new Thread(() => {
var br = new WebBrowser();
br.DocumentCompleted += PrintDocument;
br.Navigate("http://google.com");
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();
// Dispose the WebBrowser now that the task is complete.
browser.Dispose();
}
}
}