I can open a web page from within R:
shell.exec("http://stackoverflow.com/")
But how can I then print this webpage, directly from within R, as an xps or pdf file?
You can invoke a command line tool called wkhtmltopdf, which is both open source and cross-platform:
shell("C:\\wkhtmltopdf\\bin\\wkhtmltopdf http://stackoverflow.com so.pdf")
Do not forget to escape backslashes!
I realise this is an old question, but you can use the webshot
package to do this.
# install.packages("webshot")
library(webshot)
webshot("https://stackoverflow.com/", "stackoverflow.pdf")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With