Reputation: 143
I have a C# ASP.NET MVC and I'm stuck on one piece of functionality. My project is a game management system for a hobby.
After the user add a certain number of players and creates a game, it returns a view with all the games. (Two teams per game).
Each game and team are generated by two foreach loops, the first one loops through each of the games and displays them and the second one inside of it loops through the teams to display the players.
I want to add a button that says something along the lines of "Print" which will let the users download a pdf, but there needs to be only one game per page. (It's an hobby for old people, they have bad eyes)
All suggestions are welcome, I'm not exactly sure where to start.
Upvotes: 1
Views: 1402
Reputation: 778
You have options.
Depending on how you're marking up the display of the games, teams and players data, you could use a CSS file for printing. <link href="printme.css" rel="stylesheet" type="text/css" media="print" />
Display a <table>
for each game and its related data, then play with default height of the selector such that it displays only one per page when printing. The tradeoff with this is you may have to disable other tags/selectors depending on what you want to show/hide and if some game tables have a lot of data, then you could get unexpected results in the printted display.
Use an SSRS RDLC report which gives you total control over the printted display. Using MVC you allow your end users to download the PDF. This is not hard, but it is involved. Assuming you can create an RDLC file in your version of VS, here's a very high level of what you'll need to do:
private long _gameID;
public long GameID
{
get { return _gameID; }
set { _gameID = value; }
}
FileContentResult
Again the above is high level, but there are good resources on the web that can help you through it. Here's a good article to get you going
Upvotes: 1