r-markdownxaringan

How to add scrollable pdf file on xarigan slide


I learned how to insert a certain page of pdf file on my xaringan slide using the following code:

```
{r}
magick::image_read_pdf("document.pdf", pages = 1)
```

The problem is I still cannot see the item on the page because it is located in down below. So I wonder if there's any function like leaflet so that I may be able to scroll the pdf document down.


Solution

  • You can try embed a pdf file using embed html tag, like this,

    ---
    title: "Adding scrollable pdf file in xaringan"
    output: xaringan::moon_reader
    ---
    
    ```{css, echo=FALSE}
    #embeded_pdf {
     width: 100%; 
     height: 70%;
    }
    
    ```
    
    ## Adding a pdf file
    
    <embed src="lorem_ipsum.pdf" type="application/pdf" id="embeded_pdf">
    

    embeded_pdf_in_xaringan


    Note that,