Skip to content

Instantly share code, notes, and snippets.

@actaneon
Forked from mhinze/gist:205003
Created January 16, 2010 03:47
Show Gist options
  • Save actaneon/278632 to your computer and use it in GitHub Desktop.
Save actaneon/278632 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