# NOT RUN {
async_save_as_pdf <- function(url) {
function(client) {
Page <- client$Page
Page$enable() %...>% {
Page$navigate(url = url)
Page$loadEventFired()
} %...>% {
Page$printToPDF()
} %...>% {
write_base64(., paste0(httr::parse_url(url)$hostname, ".pdf"))
}
}
}
save_as_pdf <- function(...) {
list(...) %>%
purrr::map(async_save_as_pdf) %>%
perform_with_chrome(.list = .)
}
save_as_pdf("https://www.r-project.org/", "https://rstudio.com/")
# }
Run the code above in your browser using DataLab