header and footer pdf

 have a context where I have a espace to generate pdfs. Im using the HtmlToPdfConverter.

I have a web screen that receives a Id and a prepartion and I have a aggregate "GetInfo" to get some information to show in the pdf based on the Id.

In this webscreen I have a webblock inside a ListRecords that has as Source Record List the "GetInfo. The webblock receives a SectionId and in the perpation I have an aggregate "GetSectionInfo" to get the section details that will appear in the pdf, the pdf will have information about several sections.

Then I have a server action GenerateProcessPDF that has a server action "GeneratePdf", this GeneratePDF receives an url "https://localhost/Project_PDFs/GeneratePDF.aspx?ID="+ProcessId and then I have an assign with:

ResultOk = True
ErrorMessage= ""
PDFFile = GeneratePDF.PDFBinary

For now I have a screen that has a web block to show some sections id the pdf. My doubt is how to add a header and a footer to each page. The header has a logo the footer is just a horizontal bar with page number.

Hi @Jake B. , you can had a header and footer by adding the following to the action generatePDF in OtherArgs:

Headers And Footer Options:
      --footer-center <text>          Centered footer text
      --footer-font-name <name>       Set footer font name (default Arial)
      --footer-font-size <size>       Set footer font size (default 12)
      --footer-html <url>             Adds a html footer
      --footer-left <text>            Left aligned footer text
      --footer-line                   Display line above the footer
      --no-footer-line                Do not display line above the footer
      --footer-right <text>           Right aligned footer text
      --footer-spacing <real>         Spacing between footer and content in mm
                                      (default 0)
      --header-center <text>          Centered header text
      --header-font-name <name>       Set header font name (default Arial)
      --header-font-size <size>       Set header font size (default 12)
      --header-html <url>             Adds a html header
      --header-left <text>            Left aligned header text
      --header-line                   Display line below the header
      --no-header-line                Do not display line below the header
      --header-right <text>           Right aligned header text
      --header-spacing <real>         Spacing between header and content in mm
                                      (default 0)
      --replace <name> <value>        Replace [name] with value in header and
                                      footer (repeatable)

See: https://www.outsystems.com/forums/discussion/64165/not-to-add-header-on-first-page-but-needed-for-the-rest-of-the-pages/ and https://wkhtmltopdf.org/usage/wkhtmltopdf.txt for more info

Thanks, but with this:

"--header-html https://localhost/Proj_PDF/header.aspx

in "OtherArgs" the header doesn't appear.

Mmm, try using a different url domain other than localhost, since the component will access it via web. try using getEntryUrl (from httpRequestHandler) that points to the header you want to display to form the url you need.

Thanks but the header also doesnt appear with getEntryUrl("header") in the OtherArgs.

@Jake B. , then I would recommend @Salman Ansari 's answer that has a working header and footer sample in that component. you can upgrade it to the OS10 and OS11 quickly by substituting the action HtmlToPdfConverter with the current GeneratePdf in the PDF_HeaderFooter module, since a bit more parametrization of the actual header and footer are needed. 


Hi Jake,
If above will not work then please try below.

Is there any other forge component to make header visible in pdf ?

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.