Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
391 views
in Technique[技术] by (71.8m points)

asp.net - How do I do advanced printing from a web application?

I have been researching options for printing report-like data via a web application. Some options that are viable are writing PDFs, Excel XML, dumping HTML to Excel, or using a tool like activePDF webGrabber. I suppose the question is, what are some solution that give control over print from a browser (IE in my case) yet doesn't have a huge development time. Though I don't have experience with it myself, I have seen some horrid code for generating PDFs.

The features I'm looking for in particular are to print landscape or portrait without user intervention. Also, having control over basic styling is important to translate the basic look/feel of the web app to the printed format.

Any advice (especially from experience) is appreciated.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

As I've asked about here already and found out the hard way, you aren't going to get reliable and accurate printing results purely within the browser. Even if it is an intranet application that you've been promised must only work with IE7, IE8 will be out soon and then Firefox will be allowed and all of your careful micromanagement of CSS will be for naught (do I sound bitter?).

The most forward looking solution is to bite the bullet and go for generating PDFs. The tools you mentioned are good. You should also look at iText and iTextSharp. Once you get the hang of it, doing the PDF layouts isn't any harder than HTML and CSS and you will know that the results will print correctly on everyone's computer, everyone's browser, and everyone's printer. I'm currently working with iTextSharp (not finished yet, but still learning and experimenting).

I haven't found reliable ways to control the print options from within a page either, so relying on your users to change from portrait to landscape or to set or adjust margins or turn off the print headers and footers just doesn't work in the long run - you'll end up annoying them and creating more headaches for yourself when they can't (or just don't) follow instructions.

The "Related Questions" sidebar is very useful. I saw these questions on controlling the printer from the web page (both with answers that amount to: "you can't"):

Programmatically Selecting Landscape Printing

Printing to a Specific Printer


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...