Table of Contents
MVCToPDF.RenderAsPDF Method (EventHandler, PdfDocumentEventHandler)

Renders the current page as PDF.

Syntax
 public static void RenderAsPDF(
   EventHandler beforeConvertHandler,
   PdfDocumentEventHandler afterConvertHandler
);

Parameters

beforeConvertHandler
A function to be called before the conversion.
afterConvertHandler
A function to be called to perform post processing with the result PDF file before sending it to the client.
Remarks

The following code demonstrates how to use this function:

private void ConvertToPDF()
{
    //Call RenderAsPDF with Post_Handler
    MVCToPDF.RenderAsPDF(null, Post_Handler);
}

Here Post_Handler is a PdfDocumentEventHandler delegate that you can perform additional task on the conversion result. The following code demonstrates how to call saving the result into a file to save the conversion result to a file:

private void Post_Handler(object sender, PdfDocumentEventArgs e)
{
    e.Document.Save(pdf_file_name);
}
See Also