rstudio / pagedown

Paginate the HTML Output of R Markdown with CSS for Print
https://pagedown.rbind.io
Other
894 stars 127 forks source link

business cards run over page dimensions when saved as pdf #140

Open mariakharitonova opened 5 years ago

mariakharitonova commented 5 years ago

Hi, I have another question. I use the pagedown::business_card to create many cards at a time that our customers use to log into our tool, and I'm attaching an example here with fake names. As you see, when the file gets big enough, the card run over the page/margin limit, though the code should make it stay on the 8.5 x 11 page with 4 columns and 3 rows. For smaller files I can manually change the margins when manually printing to PDF but haven't been able to be successful with larger files and it "cuts" the cards in the middle. Thoughts?

---
params:
  prefix: "ex"
  school: "example_bulk_students_labels.csv"
url: https://le.selweb.com
logo: "xSEL Favicon Final.png"
paperwidth: 8.5in
paperheight: 11in
cols: 4
rows: 3
output:
  pagedown::business_card:
   template: customcard.html
---

```{r setup, include=FALSE}
library(tidyverse)
knitr::opts_chunk$set(echo = FALSE)

roster <- read_csv(paste0("/Volumes/GoogleDrive/My\ Drive/xSEL\ Labs/Rosters/2019-20/xSEL\ test/", params$school))

```

```{r data-preparation}

#prefix = "lan"

person <- purrr::pmap(roster, function(student_first_name, student_last_name, teacher_username, student_id, school_name,
                                       district_name,...) {
  list(
    name = paste0(student_first_name, " ", student_last_name),
    title = paste0("Login: ", params$prefix, ".", student_id),
    email = paste0("Teacher: ", teacher_username),
    phone = paste0("School: ", word(school_name, 1)),
    address = paste0("District: ", district_name)

    # title = paste0("Teacher: ", teacher_username),
    # email = paste0("Login: ", prefix, ".", student_id)
  )
})

```

---
```{r write-yaml, results='asis'}
cat(yaml::as.yaml(list(person = person)))
```
---

<!-- if you prefer black text on white background, set eval=TRUE on the chunk below -->

```{css, eval=TRUE}
.wrapper {
  color: black;
  background-color: white;
  border: 1px dotted black;
}
.coordinates {
  color: #333;
}
.logo {
  display: block;
  height: 15%;
  # margin-right: 0;
  # margin-top: .2in;
  # align-items: center;
  # justify-content: center
  # #padding: 0 .3in 0;
  # float: center;
}
.contact-email {
  margin-top: 0.5cm;
}
.website {
  margin-top: 1.0cm;
}
```

BusinessCard_ex.pdf

yihui commented 5 years ago

(You may want to learn more about Markdown to format your Github issue correctly: https://yihui.name/issue/#please-format-your-issue-correctly)

RLesur commented 5 years ago

@mariakharitonova I tried to have a look but the main problem I faced is that the Rmd file is not reproducible: I cannot run it on my computer and reproduce the issue.
Could you post a reproducible example, please?

Just one tip: with CSS, the # character cannot be used to comment lines, see https://developer.mozilla.org/docs/Web/CSS/Comments. IMO, this is not the problem.