Im in the situation where I need to make a webpage that can handle how to print a word document (created in the code) on the client printer. I think I should be able to create the word document but I dont know how to make it print from the printer at the client.
Any suggestions?
ChristianPosted Jan 26, 2010, 12:25 PM
Now my problem is to figure out how to print the rtf file on the client machine when the text for the rtf file is stored in a db on a webserver. I have a few ideas so maybe you can tell me what you think:
1. I generate and save the rtf file on the server and send the link to the document over to the client machine and the via javascript or activexobject (dont know what is best in this situation...)
2. Generate the text as a string or maybe even a file and the stream it to the client where it will print it via jv or activexobject.
Any ideas or other input?
Thanks for all the help so far :)
Mahesh ChandPosted Jan 24, 2010, 11:48 AM
Since you are already creating a Word document in your code, that means you have all contnets. Web Browsers already support Print featue. What you can do like other webites, build a Printable simpler version of your Webpage that should look like what users wants to see in a printed page. This is different than you creating a word doc in the code. Then have a Print button on the main page and Print it.
Here is one article that shows how to print an ASP.NET page:
One of the most common functionality in any ASP.NET application is to print forms and controls. In this article I am going to show how we can achieve this print functionality in our asp.net application.
ChristianPosted Jan 24, 2010, 8:18 AM
Andrew FensterPosted Jan 22, 2010, 11:02 AM
ChristianPosted Jan 22, 2010, 10:51 AM
I just tried opening notepad to make a quick test with the text files. I need to format the text so some of the text can be bigger or smaller and some might be bold and so on. Is it just notepad or is it impossible to format the text as I want it?
I need to write a reciet from a recietprinter so the paper has to be cut after the text stops. That is possible with word and text files. I have tried with pdf and printing a webpage but then i prints out the whole page with too much blank paper. So i dont think my options are so many unfortnatly :(
Andrew FensterPosted Jan 21, 2010, 10:54 PM
A few years ago I built this beautiful web application that would read the database, create a spreadsheet on the fly and let the user download it. Then they could modify the spreadsheet and upload it again. The application would parse the spreadsheet and update the database. It worked wonderfully. Then I noticed there were always ten or twenty instances of Excel running on the server. They weren't shutting down when processing was complete. Then I started having crashes and deadlocks. I spent a long time trying to make it go before giving up.
Good luck to you!
ChristianPosted Jan 21, 2010, 3:17 PM
What if I use .txt files instead? Would that solve the problems that I would have if I used word instead?
Andrew FensterPosted Jan 21, 2010, 1:19 AM
There are lots of articles about how to use Excel or Word on the fly inside a web application. They're everywhere. Microsoft, however, recommends that you NOT do this. See the official word from Microsoft at http://support.microsoft.com/kb/257757 .
Other people are going to provide you with lots of links and code examples about how to do this. You should stare at the Microsoft article long and hard first. There are issues with stability, scalability, memory leaks, slow performance and crashes. I've run into them myself.
As Microsoft puts it:
"Developers can use Automation in Microsoft Office to build custom solutions that use the capabilities and the features that are built into the Office product. Although such programmatic development can be implemented on a client system with relative ease, a number of complications can occur if Automation takes place from server-side code such as Microsoft Active Server Pages (ASP), ASP.NET, DCOM, or a Windows NT service."
Further on, they state:
"Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment."
Note that the bold print is in the Microsoft announcement. They really mean it.
So think twice. You can DOWNLOAD a Word document from a web page, but you shouldn't try to use Office Automation code on the server.
Sorry.
Lalit MPosted Jan 21, 2010, 12:10 AM
http://forums.asp.net/t/1416006.aspx
http://www.aspose.com/community/forums/thread/18157/printing-word-document-in-asp.net.aspx
using javascript you can print word doc from webpage
Hope this help thanks you...