---
title: "How do I print an HTML document from a web service?"  
description: "How do I print an HTML document from a web service?"  
author: "alexander sabato"  
published: 2013-02-04  
updated: 2016-12-12  
canonical: https://www.mindstick.com/forum/576/how-do-i-print-an-html-document-from-a-web-service  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# How do I print an HTML document from a web service?

Hi [Expert](https://www.mindstick.com/articles/13120/an-expert-financial-advice-will-improve-your-finances)!

How to [print](https://www.mindstick.com/blog/301752/types-of-3d-printing-technology) [HTML](https://www.mindstick.com/articles/1530/design-a-simple-stylish-calculator-using-html-css-and-javascript) [document](https://www.mindstick.com/articles/328642/what-to-consider-while-choosing-a-software-documentation-tool) using [command line](https://www.mindstick.com/forum/158085/how-do-i-pass-command-line-arguments-to-a-node-js-program) and C#.

Thanks in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)

## Replies

### Reply by Dinesh Tummala

I have tried with the above code but it will ask to Click the Print button through dialog box.\
How can i avoid this Please help me.\
I will try with the below code snippet.But it will not work.\

```
using (Process printProcess = new Process())         {                         string systemPath = Environment.GetFolderPath(Environment.SpecialFolder.System);             printProcess.StartInfo.FileName = systemPath + @"\rundll32.exe";             printProcess.StartInfo.Arguments = systemPath + @"\mshtml.dll,PrintHTML """ + document + @"""";                           printProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;             printProcess.Start();        }
```

\
When i run the above code nothing printed.Please help me with this.\
Thanks in Advance

### Reply by AVADHESH PATEL

Hi Alexander Sabato!

Run this [command](https://www.mindstick.com/blog/178/synchronous-and-asynchronous-command-execution-in-c-sharp-dot-net) into command prompt

rundll32.exe %WINDIR%\System32\mshtml.dll,PrintHTML "FilePath"

If you are using C#, than used line of code as below

```
using (Process printProcess = new Process())
{
    string systemPath = Environment.GetFolderPath(Environment.SpecialFolder.System);
    printProcess.StartInfo.FileName = systemPath + @"\rundll32.exe";
    printProcess.StartInfo.Arguments = systemPath + @"\mshtml.dll,PrintHTML """ + FilePath + @"""";
    printProcess.Start();
}
```

Note: Here "FilePath", represent path of document which you want to print.


---

Original Source: https://www.mindstick.com/forum/576/how-do-i-print-an-html-document-from-a-web-service

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
