from ironpdf import * # Initiate PDF Renderer renderer = ChromePdfRenderer() # Add a header to every page easily renderer.RenderingOptions.FirstPageNumber = 1 # use 2 if a cover page will be appended renderer.RenderingOptions.TextHeader.DrawDividerLine = True renderer.RenderingOptions.TextHeader.CenterText = "{url}" renderer.RenderingOptions.TextHeader.Font = FontTypes.Helvetica renderer.RenderingOptions.TextHeader.FontSize = 12 renderer.RenderingOptions.MarginTop = 25 # create 25mm space for header # Add a footer too renderer.RenderingOptions.TextFooter.DrawDividerLine = True renderer.RenderingOptions.TextFooter.Font = FontTypes.Arial renderer.RenderingOptions.TextFooter.FontSize = 10 renderer.RenderingOptions.TextFooter.LeftText = "{date} {time}" renderer.RenderingOptions.TextFooter.RightText = "{page} of {total-pages}" renderer.RenderingOptions.MarginBottom = 25 # create 25mm space for footer # Mergeable fields are: # {page} {total-pages} {url} {date} {time} {html-title} & {pdf-title}
添加经典文本页眉和页脚