1

I have created a flexdashboard and am trying to render both it's html file and a PDF document (client request). How can I do this from within the .Rmd file, and retain the dashboard's layout?

I am confused about where to call this in my Rmd (chunk? or is it automatic?). I have read this question but it's oudated now.

Knitr updates say to use webshot2 instead of webshot and PhantomJS ( I couldn't get those to work anyway):

The internal function html_screenshot(), which takes screenshots of HTML widgets and Shiny apps in knitr documents, now prefers the webshot2 package over the webshot package. This is because the backend of the webshot package is PhantomJS, which has been archived since 2018. If webshot is still preferred, use the chunk option opts_chunk$set(webshot = "webshot") (thanks, @atusy #1918, @LouisStAmour #1858).

When I knit using the following header and no html ggplotly() items, it prints to PDF but I lose the dashboard formatting.

---
title: "Dashboard: Site X"

output: 
  pdf_document:
    latex_engine: lualatex
#  pdf_document: default
  flexdashboard::flex_dashboard:
    orientation: rows
---

When I add back some html items, install and call library(webshot2), I get

! Text line contains an invalid character.
l.208 ##   Please report the issue at <
                                      ]8;;https://github.com/plotly/plotly.R...

Error: LaTeX failed to compile test3webshot.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See test3webshot.log for more info.
Execution halted 

I'm confused about the new latex error - I was able to knit to PDF previously, and the new ggplot/ggplotly widgets should be screenshotted by webshot, which I thought would override any latex issues? I have symbols such as %>=# in my code and labels. In my html file, I do have multiple pages but only need the default/homepage to be printed to PDF.

Cassandra
  • 137
  • 1
  • 9

0 Answers0