from ironpdf import * import os # Instantiate Renderer renderer = ChromePdfRenderer() # Build a footer using html to style the text # mergeable fields are: # {page} {total-pages} {url} {date} {time} {html-title} & {pdf-title} renderer.RenderingOptions.HtmlFooter = HtmlHeaderFooter() renderer.RenderingOptions.HtmlFooter.MaxHeight = 15 # millimeters renderer.RenderingOptions.HtmlFooter.HtmlFragment = "<center><i>{page} of {total-pages}<i></center>" renderer.RenderingOptions.HtmlFooter.DrawDividerLine = True # Use sufficient MarginBottom to ensure that the HtmlFooter does not overlap with the main PDF page content. renderer.RenderingOptions.MarginBottom = 25 # mm # Build a header using an image asset # Note the use of BaseUrl to set a relative path to the assets renderer.RenderingOptions.HtmlHeader = HtmlHeaderFooter() renderer.RenderingOptions.HtmlHeader.MaxHeight = 20 # millimeters renderer.RenderingOptions.HtmlHeader.HtmlFragment = "<img src='iron.png'>" renderer.RenderingOptions.HtmlHeader.BaseUrl = os.path.abspath("C:/Users/lyty1/OneDrive/Documents/IronPdfPythonNew") # Use sufficient MarginTop to ensure that the HtmlHeader does not overlap with the main PDF page content. renderer.RenderingOptions.MarginTop = 25 # mm
Añadir encabezados y pies de página HTML