Welcome Guest Search | Active Topics | Sign In | Register

EO.Pdf.PdfPageEventHandler not working Options
DHS
Posted: Tuesday, November 29, 2022 2:52:22 PM
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"

eo_support
Posted: Wednesday, November 30, 2022 2:20:32 PM
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.html

You 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!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.