From caadd73a1fabd10de0d61bae07200bb7e2fc7f10 Mon Sep 17 00:00:00 2001 From: Konrad Pagacz Date: Thu, 25 Apr 2024 16:50:01 +0200 Subject: [PATCH] fix: stopped rendering an empty footer (#32) * stopped rendering an empty row in cases where the footer passed to `gentlg` is of length 0 or NA Closes #31 --- R/gentlg_single.R | 9 +++++---- R/quick_rtf_jnj.R | 1 - 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/R/gentlg_single.R b/R/gentlg_single.R index 2c9b9a2..0e29da3 100644 --- a/R/gentlg_single.R +++ b/R/gentlg_single.R @@ -27,6 +27,9 @@ gentlg_single <- function(huxme = NULL, function(x) arglist[[x]] <<- eval(rlang::sym(x)) }) check_gentlg(arglist) + if (identical(footers, NA) || length(footers) == 0) { + footers <- NULL + } if (!is.null(title_file)) { title_df <- readxl::read_excel(title_file, @@ -746,7 +749,7 @@ gentlg_single <- function(huxme = NULL, if (dev.cur() == 1) { # If there is no graphics dev available. Create a NULL PDF device pdf(NULL) - filin <- round( + round( 1440 / graphics::strwidth( expression(huxtable::bold(paste0(file, ":"))), family = "serif", @@ -758,7 +761,7 @@ gentlg_single <- function(huxme = NULL, # Close the device dev.off() } else { - filin <- round( + round( 1440 / graphics::strwidth( expression(huxtable::bold(paste0(file, ":"))), family = "serif", @@ -769,8 +772,6 @@ gentlg_single <- function(huxme = NULL, ) } - - # Make repeated header on each page ht <- add_header(ht, paste0( "\\pnhang\\trhdr\\fi-1152", "\\li1152\\keepn", diff --git a/R/quick_rtf_jnj.R b/R/quick_rtf_jnj.R index 6e04cb3..c1abfda 100644 --- a/R/quick_rtf_jnj.R +++ b/R/quick_rtf_jnj.R @@ -504,7 +504,6 @@ custom_to_rtf <- function(ht, fc_tables = rtf_fc_tables(ht), watermark, tc <- huxtable::text_color(ht) ## MAKE CELLX DEFINITIONS ---- - left_merge <- ifelse(huxtable::colspan(ht) > 1, "\\clmgf", "") top_merge <- ifelse(huxtable::rowspan(ht) > 1, "\\clvmgf", "") dc <- display_cells(ht, all = TRUE)