Printing Word Document in asp.net

I have one word document,Excel and Pdf whenever user select the option whatever he want then click the print button the it’ll print the particular document how it possible in asp.net

Hi,

Printing functionality is not supported by Aspose.Word yet although we are working hard to add it as this is the most popular feature request. Please check back in several months.

Hi,
Thank you for response.
Is this possible in asp.net with out using JavaScript.Means any using Serverside coding in C#.

Sorry we don’t fully understand your request. Aspose.Word is a .NET component and normally runs in a .NET application. It can open, populate and save DOC files, but it cannot print them.

Hi,
Thank you for response,
You told that print is not possible in aspose.word.
Is it possible print a document in asp.net with out
using JavaScript.

Since Aspose.Word is a .NET component, we exactly meant use of one of the .NET languages like C# or VB .NET, not client-side JavaScript. So it is still impossible to perform printing programmatically using our component only. You can save the resulting document and then print it using Word itself or some 3rd party tools.

Hello,

It has been several months since the original posting. We are evaluating your product, and one of our requirements is to print programatically. Is printing available and if not, do you have a timeline?

Thanks,

Carlo.

Printing support is included in Aspose.Word now, although it is still in beta stage. Please give us a detailed description of your task. We can then provide you with some directions on how to implement this printing capability.

Wow! Thanks for the quick reply.

We have a few basic requirements for our ASP.NET app:

  1. Perform a mail merge and open Word with the resultant document

  2. Perform a mail merge and print directly to a SPECIFIC printer (more than likely a local printer connected to the client’s desktop) without opening Word. We also need to be able to perform this operation for a group of selected documents (essentially a for loop).

  3. Perform a mail merge and print a mailing label. Unforunately, the client is using roll label maker that doesn’t have its Avery type listed in Word. I was able to create a PDF using Crystal Reports and print properly, however, it turns out Crystal Reports is not an viable option from the client’s point of view.

As I mentioned earlier, I am evaluating your product so any help you can send my way would be greatly appreciated. I am currently trying to get the direct print to work. I am using your demo and my first attempt (before leaving for the day) was unsuccessful using:

'Create and execute the demo, it produces a document in memory.
Dim demo As demo = CreateDemo(demoName)
'This is needed so the demo knows the path to the database and to the template documents.
demo.Init(Me.MapPath("."))
Dim doc As Document = demo.Execute()
Dim dr As New Aspose.Word.Viewer.DocumentRenderer(doc)
dr.Print()

I will play around with it some more today. One other question, actually. Does anything need to be installed separately on the client’s server or do we just copy over the Aspose DLL’s with our application?

Thanks,

Carlo.

Answering from the end of your list - all you need is to copy your app and Aspose.Word.dll to the destination directory on the server (provided it has .NET installed of course).

Calling DocumentRenderer.Print is not going to help you because printing will be done on the server-side which is not what you need.

I suggest you use DocumentRenderer.GetPages property to get bitmaps of document pages and send them over to client in http response.

I think for this to work you should design a page with an image area and a set of buttons on it used to request document pages and print the acquired images.

Hi,

So, if I understand you correctly, you’re suggesting that I load the bitmap version of the Word document onto a web page and use the browser’s print functionality to print? If this is the case, I won’t be able to use it. One of the client’s requirements is to print a single or multiple documents directly without any intermediate steps. i.e. They click on the “Print” button beside the name of a document and it starts coming out on the printer at their desk.

I’m beginning to think that this is an impossible task. Any thoughts on this?

Thanks,

Carlo.

Well, I think it’s possible, just don’t know how to print directly from ASP.NET web page. Hang on, I will discuss it with my colleagues and post you back.

Carlo,

I don’t know about your situation, and I doubt this will help, but we print documents from web pages.

All of our users printers are network printers and we have a table that contains the IP address of the printer to use for each user. It’s then fairly easy to spool the document to the correct printer from a server component.

Aspose Word doesn’t currently support printer selection, although I’ve been told it will be in the next hot fix.

Rick

Hi Rick,

Thanks for your reply, however, your solution won’t work for us. We need to be able to print Word documents directly (programatically) to a local printer. It looks like Aspose will only print directly to the default printer set up on the server. Since this is a web application we are working on, the web server could be on the other side of the country.

Thanks,

Carlo.

Hi Carlo,

Aspose.Words is a server-side component so it will indeed print to a printer set up on the server (btw not only the default one starting from version 3.5). To print to a client-side printer, you should implement some client script.

Hi Dmitry,

Thanks for your reply. If I understand it correctly, Version 3.5 of Aspose.Word will support printing to other than the default printer on the server. i.e. we will be able to print to another network printer.

If so, will this scenario be possible:

  • a User’s Defaults page allows the user to select the printer they want
    • the list is the list of network printers the server can access
  • the user then clicks on a button to print a Word document
  • using Aspose.Word methods, the document is opened
  • the selected printer is passed into the print method
  • the word doc is printed on the selected printer (which could be a printer at the user’s desk assuming it is shared on the network)

It appears that printing to the local printer isn’t possible without scripting. What is the release date for Version 3.5?

Thank you for your time,

Carlo.

Your scenario seems to be possible. Aspose.Words 3.5 was released yesterday so please download it from our download page. See the DocumentRenderer.PrinterSettings property which allows setting up the required printer.

I’d like to emphasize another time that we do not normally improve the viewer beta. However, many of our customers seem to use it anyway and the ability of choosing the printer was requested lots of times.

We are happy to tell you that the new Rendering Engine has replaced the “old Viewer Beta”. The Rendering Engine can print, save as images or draw onto .NET Graphics object any document page.

Please see Aspose.Words documentation to learn more about new features.

Saving to image

In additional, new Rendering engine allows you to convert Word document to PDF directly (without using Aspose.Pdf).

Saving to Pdf

The latest version of Aspose.Words is available for download from downloads section or from NuGet