header_image: Insert an image into the page header

View source: R/report_spec.r

header_imageR Documentation

Insert an image into the page header

Description

The header_image function inserts an image into the page header. The function can be used to add a logo or other graphical element to the report. The image will then appear at the top of each page.

Usage

header_image(x, image_path, height, width, align = "left")

Arguments

x

The report object.

image_path

The path of image file. Function accepts JPG images for RTF, DOCX, PDF, and HTML output types. Function also accepts PNG images for RTF, DOCX, and HTML output types.

height

Desired height of the image, in the report units of measure.

width

Desired width of the image, in the report units of measure.

align

Alignment of the image. Valid values are "left", "right", "center", or "centre". The default value is "left".

Details

The function assumes the existence of a page header inserted by the page_header function. If there is no page header, an error will be generated during the rendering process in write_report. If there is text in the same cell as the image, the text will be disregarded. You may add text to other cells in the header.

The "align" parameter determines which page header cell the image will be inserted. That is, if you align an image "left", it will be inserted into the left column of the page header. Options are "left", "right", and "center". To insert images in multiple cells, you may use multiple calls to image_header.

The page header cell width will take priority over the image width. That is, if you set the image width larger than the cell width, the image width will be reduced to fit the cell. To make a wider image, increase the cell width on the page header.

Note that page header cells can be removed entirely by setting the width to zero. This feature can give you more room for a wide image. For instance, to create a banner image over the entire report, align the image "center" and set the left and right page header column widths to zero.

See the page_header function for more information on setting header column widths. For a demonstration of a header image insertion, see vignette("reporter-hfimage").

Value

The modified report specification.

See Also

Other report: add_content(), create_report(), footer_image(), footnotes(), options_fixed(), page_by(), page_footer(), page_header(), print.report_spec(), set_margins(), title_header(), titles(), write_report()


reporter documentation built on Feb. 7, 2026, 9:07 a.m.