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 8475365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:52:22+00:00 2026-06-10T17:52:22+00:00

I have the printer installed and working on an intranet server and I want

  • 0

I have the printer installed and working on an intranet server and I want to programmatically send “hello world” to that default printer. This seems like the simplest thing but I’ve been googling for a couple hours with no success. (note: I am developing asp.net mvc on the deployment machine itself which is running Windows 7)

I tried to translate an example from VB here into C# but it said “no printers are installed”.

public void TestPrint()
{
    var x = new PrintDocument();
    x.PrintPage += new PrintPageEventHandler(PrintPage);
    x.Print();
}
private void PrintPage(Object sender, PrintPageEventArgs e)
{
    var textToPrint = "Hello world";
    var printFont = new Font("Courier New", 12);
    var leftMargin = e.MarginBounds.Left;
    var topMargin = e.MarginBounds.Top;
    e.Graphics.DrawString(textToPrint, printFont, Brushes.Black, leftMargin, topMargin);
}

I had also tried a snippet from MSDN here but it said it did not recognize the printer name.

public void TestPrint(string msg)
{
    var server = new LocalPrintServer();
    var queue = LocalPrintServer.GetDefaultPrintQueue();

    // Call AddJob
    var job = queue.AddJob();

    // Write a Byte buffer to the JobStream and close the stream
    var stream = job.JobStream;
    var buffer = UnicodeEncoding.Unicode.GetBytes(msg);
    stream.Write(buffer, 0, buffer.Length);
    stream.Close();
}
  • 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. Editorial Team
    Editorial Team
    2026-06-10T17:52:24+00:00Added an answer on June 10, 2026 at 5:52 pm

    Print “hello world” server-side in .NET

    1. Share the printer
    2. Create a PrintDocument object
    3. Reference the printer by name
    4. Add a method to provide content
    5. Print

    Code

    using System.Drawing;
    using System.Drawing.Printing;
    
    public void Print()
    {
      var doc = new PrintDocument();
      doc.PrinterSettings.PrinterName = "\\\\deployment-machine-name\\share-name";
      doc.PrintPage += new PrintPageEventHandler(ProvideContent);
      doc.Print();
    }
    public void ProvideContent(object sender, PrintPageEventArgs e)
    {
      e.Graphics.DrawString(
        "Hello world",
        new Font("Arial", 12),
        Brushes.Black,
        e.MarginBounds.Left,
        e.MarginBounds.Top);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a printer that doesn't have the driver for my windows server 2008,
I have a webpage that activates a print job on a printer. This works
I have four computers and one printer in Intranet and I installed WAMP on
I installed a PostScript printer driver and have setup REDMON (redmonnt.dll) for redirecting postscript
I have program that sends a file to a printer using 'lpr' command. I
Hello I've been working on a Javascript 8 slider puzzle (that is working including
I would like to be able to have a Printer installed on a windows
Where does the CherryPy server write its error logs to? I have installed CherryPy
Hello i have a Macbook pro with osx 10.7. I just installed Qt (nokia),
I'm working on a script that needs to set up a Xerox Phaser printer

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.