9

I have a view with HTML tables, filled with information that I want to print in ASP.NET MVC 4 and C#.

I don't know the actual code that prints the document, any help will be appreciated

1
  • Print manually in the browser or create for example a PDF and send it to a printer? Commented Jul 9, 2013 at 9:16

1 Answer 1

17

Well you have two choices

  1. Either use JS

    <a href="javascript:window.print()">Click to Print This Page</a>

  2. Or print to a PDF using Action Result in MVC

For the JS option you will want to build a print css file so as to best render the page during printing, also hide some element that you don't need to appear - menus for example.

Sign up to request clarification or add additional context in comments.

3 Comments

For some reason the editor window didn't want to format the code properly... Feel free to edit it, may be a chrome issue?
how can i print a div only(in case i dont want to include the menus and other thing came from master page)..
If you check that print css link and look at the Remove unwanted items section, essentially you have a .noprint {display: none;} class and put that on all the items you don't want to show. Then put .noprint only in your print stylesheet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.