This gist consists of a makefile
and a script
that can automate the creation of PDFs from Slidify generated HTML slides. The script assumes that the makefile
and the script makepdf.js
are in the same directory as the Rmd
file. The makepdf.js
script uses casperjs, a very useful utility to automate tasks that require browser interaction. You may follow the installation instructions on the casperjs website, to make sure that you have all the dependencies correctly installed before trying this out.
Created
January 30, 2014 00:33
-
-
Save ramnathv/8700285 to your computer and use it in GitHub Desktop.
Creating PDF Version of Slidify Presentations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELAY = 1000 | |
RMD_FILE = $(wildcard *.Rmd) | |
HTML_FILE = $(patsubst %.Rmd, %.html, $(RMD_FILES)) | |
PDF_FILE = $(patsubst %.html, %.pdf, $(HTML_FILES)) | |
pdf: $(PDF_FILE) | |
html: $(HTML_FILE) | |
all: pdf html | |
%.pdf: %.html | |
casperjs makepdf.js $< $@ $(DELAY) | |
%.html: %.Rmd | |
cd $(dir $<) && Rscript -e "slidify::slidify('index.Rmd')" && cd .. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var casper = require('casper').create({viewportSize:{width:1500,height:1000}}); | |
var args = casper.cli.args; | |
var imgfile = (args[1] || Math.random().toString(36).slice(2)) | |
casper.start(args[0], function() { | |
this.wait(args[2], function(){ | |
this.captureSelector(imgfile, "slides"); | |
}); | |
}); | |
casper.run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Really like this information thank you very much, I am a novice so took me a minute to figure out how to call the script and make it work, you may want to add that to this.