Initially I was just using a template file, but I was getting weird results with some pages having no header/footer, but then later on the header/footer would reappear with correct page numbers.
So I switched to trying to specify the header/footer as was referenced here.
My code thus far:
srcfile <- here("templates/image.png")
header_template <- function(txt) {
block_list(
fpar(ftext(txt, prop = header_font),
external_img(src = srcfile,
width = 2.89, height = 1.11,
unit = "cm"),
#
# "this is page number ",
# run_word_field(field = "PAGE \* MERGEFORMAT"),
fp_p = fp_par(padding = 0,
line_spacing = 1,
text.align = "right")
)
)
}
footer_template <- function(txt) {
block_list(
fpar(ftext(txt, prop = footer_font),
fp_p = fp_par(text.align = "left")),
fpar(ftext(run_word_field(field = "PAGE \* MERGEFORMAT"), prop = footer_font),
ftext("|Page", prop = footer_font),
fp_p = fp_par(text.align = "right"))
)
}
sec_pr <- prop_section(
header_default = header_template("Protected A "),
footer_default = footer_template("Sector Information, Analysis & Reporting"),
type = "continuous"
)
However there are a couple elements I haven’t figured out how to do. First is the positioning of the header image, the original template I had set the text wrap as in front, the vertical absolute positioning at -0.77 below paragraph and the horizontal absolute positioning at 15.18cm to the right of Column. I have no idea how to implement I have the alignment set to “right” which is decent, but doesn’t account for the vertical element.
The second thing is I have a two part footer, some static text on the left, and a page number on the right. I was trying to set the text to each side by using the fp_par element of fpar and using two calls to it within the block_list call. However this errors out. Haven’t tried doing some kind of section_columns() just yet, but that may be what I try next.