Skip to content

Instantly share code, notes, and snippets.

@mhinze
Created October 8, 2009 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mhinze/205003 to your computer and use it in GitHub Desktop.
Save mhinze/205003 to your computer and use it in GitHub Desktop.
public class BaseReportPage<TModel> : BaseViewPage<TModel>, IViewBase where TModel : class
{
// ...
protected override void OnPreInit(EventArgs e)
{
if (ShowAsPdf)
{
string path = _configuration.GetPrincePath();
var prince = new Prince(path);
prince.SetBaseURL(Request.Url.AbsoluteUri);
prince.AddStyleSheet(Server.MapPath("~/css/Styles.css"));
prince.AddStyleSheet(Server.MapPath("~/css/ReportModules/Redefinitions.css"));
prince.SetLog("prince.log");
Response.Clear();
Response.Filter = new PrinceFilter(prince, Response.Filter);
Response.AddHeader("Content-Type", "binary/octet-stream");
Response.AddHeader("Content-Disposition", "attachment; filename=Report.pdf;");
}
base.OnPreInit(e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment