views:

44

answers:

5

Hello. I am re-engineering a windows application to be ported to web. One area that has been worrying is 'printing'.

The application is data intensive and complex reports need to be generated. The erstwhile windows application takes advantage of printer APIs and extends sophisticated control to the users. It supports functions like page break, avoiding printing on printed parts of the sheet (like letterhead), choice of layouts and orientation, etc. Please note that these setting are not done only while printing, they are part of report definition sometimes.

From what I know, we cannot have this kind of control while printing web pages. I am in a process of identifying options at my disposal. While I prefer to first look into something that will help me print from raw web pages, following are other thoughts:

  1. Since reports can also be exported to .xls & .pdf versions, let user download one and print directly. This however limits my solution to the area of application that have export feature.
  2. Use Silverlight (4.0) for report layout definition and print. I think Silverlight 4.0 (in beta right now) provides adequate control over the printer. I have so far been avoiding the need of any RIA plugin.
  3. Meticulously generate reports on web with fixed dimensions. I am not sure how far this will go.

Please share practices that can be applied easily in my scenario.

+3  A: 

For reporting in the past on the web, using .NET, I like to generate PDF, Excel, Word or CSV files. I really like iTextSharp which allows for creating of PDF's.

Word can accept HTML, so that is usually quote easy. For more control you can get into the Word interops, but they left me frustrated. Not for implementation, but I felt the clean up was poor.

CSV are great for raw data dumps and that is it.

For HTML, you can get nice control using a style sheet targeted to print media. There are just certain things you cannot control, like browser header and footer.

Dustin Laine
a few choice bits on style sheets for print media:http://www.alistapart.com/articles/boom/http://www.alistapart.com/articles/goingtoprint/http://www.alistapart.com/articles/printtopreview/
Regis Frey
Thanks. I will try this first and see how far I can go.
Kabeer
A: 

Flash also has better print controls than plain HTML, though you might not know it since these features are rarely used by flash developers. Almost everyone should have Flash installed these days, so it's not like Silverlight where there's a good chance of someone needing to install a plugin (doubly so for a beta version). I am not sure how the Flash printer APIs compare to Silverlight's printer APIs and if they give you the level of control you need, but their documentation is public so you can look into it.

Also I think exporting to PDF is a good idea. I don't see why you can't extend this to cover all places that would need to print a report. Basically instead of printing directly from the windows app running on their desktop, the same exact code runs on your server and generates a PDF that they can then print themselves.

davr
A: 

I don't think you're going to have much luck trying to do it with raw HTML unfortunately. For one of our clients, we went with the "generate PDF" route and it worked out quite well. PDFs have the additional advantage that you don't have to print them out: you can just email them to the boss/accountant/whatever saving a bit of paper.

Dean Harding
A: 

PDF is the way to go, if you want absolute control over printed output. As bonus, you can also provide the option to download PDFs in your application.

With HTML, you are at the mercy of user's browser settings for page size, margin and how page breaks will be handled.

Imran
A: 

Then go for FastReport.Net. It gives you a lot of opportunities to change your report when creating, previewing and exporting. You can change a lot and design the report in accordance with your needs. Check the examples and demos here.

HERBERTS