Converting from HTML/CSS to pdf using pandoc in R

Asked

Viewed 64 times

3

Folks I’m having trouble converting my generated html/css file into Rmarkdown.

You could help me?

Follow my code:

My file . Rmd

---
title: "Table"
output:
  html_document:
    css: "test.css"
---

```{r}
library(knitr)
data(iris)
kable(iris)
```  

My file . css:

.main-container { 
     max-width: 1600px !important;
 } 
    tr:nth-child(even) {background-color: #f2f2f2}
    th {
        background-color: #FF6319;
        color: white;
        font-size: 12px;
    }
    tbody {
        font-size: 12px;
    }
    hr {
        page-break-after: always;
    }

When I turn the remote: rmarkdown::pandoc_convert("C:/Users/user/Downloads/myfile.html", output = "meuarquivo.pdf")

PDF is generated but not customized in . css

I also tried to use google Chrome for this and nothing.

What needs to be done to correct this?

Thank you very much, guys

1 answer

2


In general way Pandoc will use LateX to convert to pdf. One option is to configure the style in language LateX.

So that Pandoc can interpret css as style, you will need to install wkhtmltopdf:

pandoc -t html5 --css test.css test.html -o output.pdf

Browser other questions tagged

You are not signed in. Login or sign up in order to post.