473,387 Members | 3,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Printing HTML in C#

233 100+
I have a C# console application, that I may need to switch to a form, that I would like to print HTML documents from. Currently I am printing through the shell with:

Process printjob = new Process();
printjob.StartInfo.FileName = @"path to HTML";
printjob.StartInfo.UseShellExecute = true;
printjob.StartInfo.Verb = "print";
printjob.StartInfo.CreateNoWindow = true;
printjob.Start();

My only issue here is that I do not know how to automate the process, i.e., no print dialog. I have thought about using the web browser class, but I would need to switch to a windows form application.

Are there any other methods to print HTML with C#, or is there a way to eliminate the print dialog from popping up with my current method?
Dec 4 '07 #1
5 15555
mcfly1204
233 100+
I realize this question is pretty out there. I am sure no one has ever had the need to print HTML docs with c# before, but I am still hoping someone will have some insight into the topic.
Dec 5 '07 #2
Plater
7,872 Expert 4TB
It has come up a number of times. Unfortunatly I never saw a good answer.
You can try using the WebBrowser object (you don't need to have it visible on the form to use it) it has it's own PRINT methods that allow printing to be done with formating and selection of PrintDocument and all that.
Actually I like your Process Call better though and might try it when I get the chance.

If you find a good way to print html AS html (instead of source text) I would love to hear it because I could use it.
Dec 5 '07 #3
mcfly1204
233 100+
If you find a good way to print html AS html (instead of source text) I would love to hear it because I could use it.
When you say print HTML as HTML, as opposed to source text, I would assume you mean printing HTML as it is intended to be formatted?
Dec 5 '07 #4
Plater
7,872 Expert 4TB
When you say print HTML as HTML, as opposed to source text, I would assume you mean printing HTML as it is intended to be formatted?
yeah, as it would appear in a web browser and not have the paper come out of the printer with "<html> ...</html>"
Dec 5 '07 #5
mcfly1204
233 100+
yeah, as it would appear in a web browser and not have the paper come out of the printer with "<html> ...</html>"
I only asked because mine print out as they would appear in a web browser. I had to make sure no style sheets were being referenced, which they weren't, so give it a try.
Dec 5 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Mark Preston | last post by:
Admission first - I don't actually have a problem here but have noticed that a lot of people have been asking similar questions and getting very varied answers. What I've done is to sort of...
7
by: Dennis C. Drumm | last post by:
I was wondering if someone could suggest were/how I could get started with setting up printing of a collection of text that includes tables from a grid and other supporting information about the...
3
by: Ahmad Abu-Raddad | last post by:
Hey Guys, Does anyone knows of a way to print HTML source directly to the printer (Server Side)?. I tried the PrintDocument class and the e.Graphics.DrawString and e.Graphics.DrawImage() but...
1
by: Raymond Du | last post by:
Hi, I have serveral web forms used by users, these users often use IE browser print function to print out the form, the problems I have is what users see on the screen is usually different from...
7
by: Amirallia | last post by:
Hello! I have a wecontrol table in a page, this table has a number of variable rows depending of the choice of the user. But when the table has a large number of rows, the printing of the page...
2
by: Jurjen de Groot | last post by:
I'm about to start a new ASP.NET application, this application will generate several types of documents (PDF HTML XML-DOC) wich have to be printed at the client-side... (probably on different...
12
by: Alex Clark | last post by:
Greetings, (.NET 2.0, WinXP Pro/Server 2003, IE6 with latest service packs). I've decided to take advantage of the layout characteristics of HTML documents to simplify my printing tasks, but...
4
by: Lucas Ponzo | last post by:
Hi All, I have an ASP.NET 2.0 app. The users access the pages, uniquely via pocket pc ... I need to print a page. But I need that the page print on a printer installed on the web server...
8
by: Neo Geshel | last post by:
Greetings. BACKGROUND: My sites are pure XHTML 1.1 with CSS 2.1 for markup. My pages are delivered as application/xhtml+xml for all non-MS web clients, and as text/xml for all MS web...
0
by: nikhilgargi | last post by:
Requirement: I need to provide printing capability in a C# desktop application that I am developing The documents that need to be printed can be in Rich Text Format (RTF) or HTML. Custom...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.