Commit 08540ed7 authored by Romain Lesur's avatar Romain Lesur

add paginate button experiment

parents
.Rproj.user
.Rhistory
.RData
.Ruserdata
# tests-pagedjs
This repository contains my personal tests with `paged.js`.
The goal of these tests is to use `paged.js` with the [`rmarkdown`](https://rmarkdown.rstudio.com/) and [`bookdown`](https://bookdown.org/yihui/bookdown/) `R` package.
<script>
function addStyle() {
var link = document.createElement("link");
link.rel = "stylesheet";
link.href = "viewer.css";
link.type = "text/css";
document.head.appendChild(link);
}
function addPagedjs() {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://unpkg.com/pagedjs/dist/paged.polyfill.js";
document.getElementsByTagName("head")[0].appendChild(script);
}
function showPages() {
document.querySelector("#paginate").style.display = "none";
addStyle();
addPagedjs();
};
function addPaginateButton() {
var button = document.createElement("button");
button.innerHTML = "Paginate";
button.setAttribute('class', 'btn btn-primary');
button.setAttribute('id', 'paginate');
button.style.position = "fixed";
button.style.top = 0;
button.style.right = 0;
var el = document.body.appendChild(button);
el.addEventListener('click', showPages);
}
//addPaginateButton();
$(document).ready(addPaginateButton);
</script>
---
title: "A simple paginate button for html_document"
author: "Romain Lesur"
date: "30 septembre 2018"
output:
html_document:
css: styles.css
theme: journal
includes:
after_body: after_body.html
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Overview
In order to render math with `mathjax` or htmlwidgets, `paged.js` has to be called after the DOM is built.
This html_document implements a paginate button that renders the document (see the upper right corner).
Before clicking on the button, the user can modify the `DT::datatable` widget.
Some tests have been made with `leaflet` and `plotly`: canvas are not rendered by `paged.js`.
## R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r cars}
summary(cars)
```
## Including Plots
You can also embed plots, for example:
```{r pressure, echo=FALSE}
plot(pressure)
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
## Some math
$$\frac{n!}{k!(n-k)!} = \binom{n}{k}$$
## A datatable widget
```{r}
DT::datatable(iris)
```
## Other widgets
Canvas elements are not rendered by paged.js.
\ No newline at end of file
This diff is collapsed.
@page{
size: A4;
margin-left: 15mm;
margin-right: 15mm;
margin-bottom: 15mm;
margin-top: 15mm;
}
.pagedjs_margin-top-left, .pagedjs_margin-top-right { height: 6px; margin-top: 10mm; }
.pagedjs_margin-top { align-items: top; }
@media screen {
body {
background-color: whitesmoke !important;
}
.pagedjs_page {
background-color: white !important;
box-shadow: 0 0 0 2px #888 !important;
margin: 0 auto !important;
margin-top: 10mm !important;
}
}
Version: 1.0
RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default
EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8
RnwWeave: Sweave
LaTeX: pdfLaTeX
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment