/// <summary>
        /// The BeforeRenderPdfPageEvent event handler where a background image is set in each PDF page
        /// before the main content is rendered
        /// </summary>
        /// <param name="eventParams">The event parameter containing the PDF page being rendered</param>
        void htmlToPdfConverter_BeforeRenderPdfPageEvent(BeforeRenderPdfPageParams eventParams)
        {
            if (formCollection["addBackgroundImageCheckBox"][0] == null)
            {
                return;
            }

            // Get the PDF page being rendered
            PdfPage pdfPage = eventParams.Page;

            // Get the PDF page drawable area width and height
            float pdfPageWidth  = pdfPage.ClientRectangle.Width;
            float pdfPageHeight = pdfPage.ClientRectangle.Height;

            // The image to be added as background
            string backgroundImagePath = m_hostingEnvironment.ContentRootPath + "/wwwroot" + "/DemoAppFiles/Input/Images/background.jpg";

            // The image element to add in background
            ImageElement backgroundImageElement = new ImageElement(0, 0, pdfPageWidth, pdfPageHeight, backgroundImagePath);

            backgroundImageElement.KeepAspectRatio = true;
            backgroundImageElement.EnlargeEnabled  = true;

            // Add the background image element to PDF page before the main content is rendered
            pdfPage.AddElement(backgroundImageElement);
        }
        /// <summary>
        /// The BeforeRenderPdfPageEvent event handler where a background image is set in each PDF page
        /// before the main content is rendered
        /// </summary>
        /// <param name="eventParams">The event parameter containing the PDF page being rendered</param>
        void htmlToPdfConverter_BeforeRenderPdfPageEvent(BeforeRenderPdfPageParams eventParams)
        {
            if (!addBackgroundImageCheckBox.Checked)
            {
                return;
            }

            // Get the PDF page being rendered
            PdfPage pdfPage = eventParams.Page;

            // Get the PDF page drawable area width and height
            float pdfPageWidth  = pdfPage.ClientRectangle.Width;
            float pdfPageHeight = pdfPage.ClientRectangle.Height;

            // The image to be added as background
            string backgroundImagePath = Server.MapPath("~/DemoAppFiles/Input/Images/background.jpg");

            // The image element to add in background
            ImageElement backgroundImageElement = new ImageElement(0, 0, pdfPageWidth, pdfPageHeight, backgroundImagePath);

            backgroundImageElement.KeepAspectRatio = true;
            backgroundImageElement.EnlargeEnabled  = true;

            // Add the background image element to PDF page before the main content is rendered
            pdfPage.AddElement(backgroundImageElement);
        }