Solved

Saving Printer Settings

Posted on 2010-09-13
3
886 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 13

Expert Comment

by:copyPasteGhost
ID: 33664139
0
 
LVL 16

Accepted Solution

by:
kris_per earned 500 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
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!
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

726 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