Skip to contents

Reads in a .docx file and returns a finalized version with magic strings and bookmarks removed.

Usage

finalize_document(docx_in, docx_out = NULL)

Arguments

docx_in

Path to input .docx to finalize

docx_out

Path to output .docx to save to

Examples

if (FALSE) { # \dontrun{

# ---------------------------------------------------------------------------
# Load all dependencies
# ---------------------------------------------------------------------------
docx_in <- file.path(here::here(), "report", "shell", "template.docx")
figures_path <- file.path(here::here(), "OUTPUTS", "figures")
tables_path <- file.path(here::here(), "OUTPUTS", "tables")
footnotes <- file.path(here::here(), "report", "standard_footnotes.yaml")

# ---------------------------------------------------------------------------
# Step 1.
# Run the wrapper function build_report() to replace figures, tables, and
# footnotes in a .docx file.
# ---------------------------------------------------------------------------
build_report(
  docx_in = docx_in,
  docx_out = doc_dirs$doc_draft,
  figures_path = figures_path,
  tables_path = tables_path,
  standard_footnotes_yaml = footnotes
)

# ---------------------------------------------------------------------------
# Step 2.
# If you are happy with the report and are ready to finalize the document.
# ---------------------------------------------------------------------------
finalize_document(
  docx_in = doc_dirs$doc_draft,
  docx_out = doc_dirs$doc_final
)
} # }