Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 175787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:45:39+00:00 2026-05-11T13:45:39+00:00

I finally figured out how to print transformed XML without prompting the user or

  • 0

I finally figured out how to print transformed XML without prompting the user or showing an IE window, but now I need to specify a number of copies and possibly other printer settings.

Is there a way to programmatically change printer settings on a WebBrowser control?

The code in question:

private static void PrintReport(string reportFilename) {     WebBrowser browser = new WebBrowser();      browser.DocumentCompleted += browser_DocumentCompleted;      browser.Navigate(reportFilename); }  private static void browser_DocumentCompleted     (object sender, WebBrowserDocumentCompletedEventArgs e) {     WebBrowser browser = sender as WebBrowser;      if (null == browser)     {         return;     }      browser.Print();      browser.Dispose(); } 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T13:45:40+00:00Added an answer on May 11, 2026 at 1:45 pm

    The only method I’ve had success with is modifying the registry on the fly (and changing them back to not affect anything else).

    You can find the settings you need at ‘Software\Microsoft\Internet Explorer\PageSetup’ under CurrentUser.

    To change the printer, you can use this:

    using System.Management  public static bool SetDefaultPrinter(string defaultPrinter) {     using (ManagementObjectSearcher objectSearcher = new ManagementObjectSearcher('SELECT * FROM Win32_Printer'))     {         using (ManagementObjectCollection objectCollection = objectSearcher.Get())         {             foreach (ManagementObject mo in objectCollection)             {                 if (string.Compare(mo['Name'].ToString(), defaultPrinter, true) == 0)                 {                     mo.InvokeMethod('SetDefaultPrinter', null, null);                     return true;                 }             }         }     }     return false; } 

    As for the number of copies, you can always put the WebBrowser.Print in a while loop.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have finally figured out how to generate a random number, but the compiler
I finally found out the difference between UTC and GMT by making the effort
I'm finally getting my team to embrace source code management now that we're working
Well the docs finally said it, I need to take it easy on my
I finally got my group to switch from SourceSafe to Subversion. Unfortunately, my manager
I finally have a hardware guy that is insterested in controlling the firmware. This
I have finally finished my web site. I published it, and I was surprised
Since there is no finally in C++ you have to use the RAII design
I've finally completed a working version of my first ever CSS-supported site (thanks to
I have finally got the green light to use Memcached in our project (after

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.