Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Saving Printer Settings

Posted on 2010-09-13
3
Medium Priority
?
927 Views
Last Modified: 2012-05-10
I am using the PrintDialog class in c# to display the printer setup dialog so that the user can modify the printer settings.  How do you save the printer settings to a text file?
0
Comment
Question by:harry12
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 16

Accepted Solution

by:
kris_per earned 2000 total points
ID: 33666008

PrinterSettings is available in PrintDialog.Document.PrinterSettings after the printing is done...Try saving the PrinterSettings object as xml using XmmlSerialiser. Sample code below:

private void button1_Click(object sender, EventArgs e)
        {
            PrintDocument pd = new PrintDocument();
            pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);            
            pd.PrinterSettings.PrinterName = "HP LaserJet 1111";

            printDialog1.Document = pd; // printDialog1 was added in form designer from controls Toolbox
            printDialog1.ShowDialog();

            // printing has finished; now save PrinterSettings to xml

            StreamWriter sw = new StreamWriter("printerSettings.xml");

            XmlSerializer x = new XmlSerializer(typeof(PrinterSettings));

            x.Serialize(sw, pd.PrinterSettings);

            sw.Close();
        }

        private void pd_PrintPage(object sender, PrintPageEventArgs ev)
        {
            // do the actual document printing here
        }

Open in new window

0
 

Author Closing Comment

by:harry12
ID: 33666963
Just what I needed.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question