Generating downloadable reports (rmarkdown) : reference_docx (yaml header) is not read by knitr

rmarkdown

#1

Hi everyone,

I carry out a Shiny app to generate downloadable reports. User can export the report as a html, pdf or MS Word document as well.
I use another MS Word template that the one provided by default. Hence, I use knitr option "reference_docx" (see Happy collaboration with Rmd to docx http://rmarkdown.rstudio.com/articles_docx.html).

On Rstudio, when I knit the Rmd file, everything works fine: styles are passed from the styles reference docx file to the final docx report but, when I tried to implement this on the shiny app the final report is generated without any style.
It seems that the reference docx is not read.
Yet, reference docx and Rmd file are both in the same directory...

Thank you for your help,

Laurent

For your information, below you can find an overview of the YAML header

---
author: "John Doe"
date: '`r format(Sys.time(), "%B-%Y")`'
output:
  word_document:
    toc: true
    toc_depth: 4
    keep_md: true
    reference_docx: mystyle.docx
  pdf_document:
    toc: true
    toc_depth: 4
    fig_caption: true
    keep_tex: true
  html_document:
    toc: true
    toc_depth: 4
    number_sections: true
params:
  csv.header: NA
  csv.name: NA
  csv.quote: NA
  csv.sep: NA
  csv.skip: NA
  csv.asfactor: NA
  csv.encoding: NA
  csv.colnames: NA
  csv.dec: NA
  csv.datapath: NA
  csv.columnsid: NA
  datasite: NA
  fraction: NA
  subset: NA
  longversion: NA
  withaustria: NA
  width.fig: 6
  height.fig: 4.5
  dpi.fig: 300
title: '`r paste("Grimm demonstration of equivalence", params$datasite, sep = " : ")`'
header-includes:
- \usepackage{pdflscape}
- \newcommand{\blandscape}{\begin{landscape}}
- \newcommand{\elandscape}{\end{landscape}}
- \usepackage{pdfpages}
- \usepackage[utf8]{inputenc}
- \usepackage[T1]{fontenc}
- \usepackage{longtable}
- \usepackage{float}
---

#2

Hi, Laurent,
I have the same issue...
I just solved it by changing the render function in my server like this :
render('report_name.Rmd',encoding="utf-8",
word_document(reference_docx = "template_name.docx"))

Hoping it will work !
Bye