Slides written in Rmd missing pages when converting from HTML to PDF

I'm trying to convert a set of slides written in Rmarkdown and outputted in HTML with xaringan::moon_reader into PDF, and I used pagedown::chrome_print() to convert to PDF.

The issue is, the converted PDF has its title page missing as well as random pages throughout the slides. I tried to manually print the HTML file with Chrome and other browsers in an attempt to save to PDF, but they have the same missing pages.

I'm open to any advice on how to export to PDF without any pages missing. It doesn't have to be chrome_print() as long as the slides can be exported in PDF successfully.

Here's a reproducible pseudocode of the slides:

---
title: document_title
author: author_name
output: 
  xaringan::moon_reader:
    css: [default, metropolis, metropolis-fonts] 
    lib_dir: libs
    nature:
      ratio: '4:3'
      highlightStyle: github
      highlightLines: true
      countIncrementalSlides: false
editor_options: 
  chunk_output_type: console
---
count: false
<style>

.center2 {
  margin: 0;
  position: absolute;
  top: 50%;
  left: 50%;
  -ms-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
}


pre.sourceCode {
    max-height: 200px;
    overflow-y: auto;
}


/*
.remark-slide-number {
  position: inherit;
}

.remark-slide-number .progress-bar-container {
  position: absolute;
  bottom: 0;
  height: 4px;
  display: block;
  left: 0;
  right: 0;
}

.remark-slide-number .progress-bar {
  height: 100%;
  background-color: blue;
}
*/
</style>


# only using two backticks for codechunks in rmd to escape ending the codeblock on stackoverflow
``{css, echo=FALSE}

@media print {
  .has-continuation {
    display: block !important;
  }
}

``


``{r setup, include=FALSE}
options(htmltools.dir.version = FALSE)
library(knitr)
opts_chunk$set(
  fig.align="center",  
  fig.height=4,
  dpi=300, 
  cache=T , 
  echo=F 
  )
library(tidyverse)
library(hrbrthemes)
library(fontawesome)

``
count: true

# Slide 1

</br>
.font130[

1. Content 1

2. Content 2

]

---
count: false
# Slide 2
</br>
.font130[

Content for slide 2
]
---

``{r gen_pdf, include = FALSE, cache = FALSE, eval = TRUE}
pagedown::chrome_print("slides.html", output = "slides.pdf")
``

We have count:true and count: false throughout the documents but it doesn't seem to relate to whether the page is missing or not.

Thank you so much in advance! :slight_smile:

I've figured out what went wrong with my slides for anyone having the same issue:

So in the end it does have something to do with count: true or count: false

count: true indicates the start of a page, but count: false adds on new information on the same page on html format, but all the intermediate results are covered by whichever section that is your last count: false section.

An example would be :

---
count: true 
Content 1
---
count: false
Content 2
---
count: false
Content 3

In this case Content 1 would be the start of a new page and everything will show up fine in .html, but on the pdf it was converted to, only Content 3 will show up, and not Content 1 or 2.

Title page was set to count: true automatically, but if you have a count: false section right after it, it will not show up.

Hopefully this explains it!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.