Rank: Newbie Groups: Member
Joined: 8/4/2014 Posts: 4
|
EO.Pdf.HtmlToPdf.Options.AfterRenderPage = new EO.Pdf.PdfPageEventHandler(On_AfterRenderPage);; EO.Pdf.Mvc.MVCToPDF.RenderAsPDF();
private void On_AfterRenderPage(object sender, EO.Pdf.PdfPageEventArgs e) { if (e.Page.Index == 0) { string fistheader; headerWhiteout = "my Header"; var outputArea = EO.Pdf.HtmlToPdf.Options.OutputArea; EO.Pdf.HtmlToPdf.Options.OutputArea = new System.Drawing.RectangleF(0, 0, 9.5f, 10.0f); EO.Pdf.HtmlToPdf.ConvertHtml(headerWhiteout, e.Page.Document.Pages[0]); EO.Pdf.HtmlToPdf.Options.OutputArea = outputArea; }
} My MVC project does not fire "On_AfterRenderPage"
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi, MVCToPDF does not use all HtmlToPdfOptions --- it only uses simple values that can be "serialized" since a serilization/deserilaization process of HtmlToPdf.Options occurs as ASP.NET switches between threads. In order to perform "post process" on pages, you can use this RenderAsPDF override instead: https://www.essentialobjects.com/doc/eo.pdf.mvc.mvctopdf.renderaspdf_overload_1.htmlYou would then add the additional output in your postHandler. The code will be largely the same except for you would use e.Document.Pages[0] instead of e.Page.Document.Pages[0]. Hope this helps. Please let us know if you have any more questions. Thanks!
|