コード例 #1
0
        /// <summary>
        /// The handler for HtmlToPdfConverter.PrepareRenderPdfPageEvent event where you can set the visibility of header and footer
        /// in each page or you can add a custom header or footer in a page
        /// </summary>
        /// <param name="eventParams">The event parameter containin the PDF page to customize before rendering</param>
        void htmlToPdfConverter_PrepareRenderPdfPageEvent(PrepareRenderPdfPageParams eventParams)
        {
            if ((eventParams.PageNumber == 1) && changeHeaderAndFooterCheckBox.Checked)
            {
                // Change the header and footer in first page with an alternative header and footer

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

                // Add a custom header of 80 points in height to this page
                // The default document header will be replaced in this page
                pdfPage.AddHeaderTemplate(80);
                // Draw the page header elements
                DrawAlternativePageHeader(pdfPage.Header, true);

                // Add a custom footer of 80 points in height to this page
                // The default document footer will be replaced in this page
                pdfPage.AddFooterTemplate(80);
                // Draw the page header elements
                DrawAlternativePageFooter(pdfPage.Footer, true, true);
            }
        }