Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing XSLT Transformed HTML on the Server

Status
Not open for further replies.

nscheu

Technical User
Sep 10, 2001
10
0
0
US
Hello,

I am using a XML and XSLT to render a HTML page.

My problem is that based on the input that the user selects different values are put into the XML and the HTML is the same (i.e. format) but displayed with different values. I am trying to create a print all button where I will loop through all the xml documents, render the html using the XSLT page and then send the html right to the printer. Also I want this all done on the server.

Here is some of the code I use:

// Get the transformed result from xml to html
StringWriter sw = new StringWriter();
xslt.Transform(doc, null, sw, null);
//hold the html
string result = sw.ToString();

The "result" string holds the html. Is there anyway to send this to the printer so that it knows that this is an html document and print it as a formatted html document? Again I want to do this all on the server.

Hopefully this is clear, let me know if more detail is required. Any help would be greatly appreciated. Thank you.
 
If you want to Print out the HTML on the client/users printer then the server cannot do this for you. It can only print to its own printers. That is the nature of a client - server relationship...

You could add the following javascript to the body tag to force the returned page to print when it loads on the client..

<body onload=&quot;window.print();&quot;>

but I for one think it bad practice to force this sort of action on the client machine without the users choosing to initiate it...

Rob

Go placidly amidst the noise and haste, and remember what peace there may be in silence - Erhmann 1927
 
Thanks for the response.

Couple things:

1. Internal users would only be allowed to use this &quot;print all&quot; feature, which means I can choose a print to a specific printer on the network. Sorry i forgot to mention that.

2. I attempted to use the window.print() function however I dont want the user to have to keep there window open while every document is sent to the printer, and the print dialog box appears every time it is about to print a new document.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top