[R] Getting file name from pdf device?
cameron.bracken
cameron.bracken at gmail.com
Fri Jul 31 21:18:39 CEST 2009
Rainer M Krug-6 wrote:
>
> Hi
>
> IU would like to modify the dev.off function, so that it automatically
> compresses the created pdf.
> I am thinking of doing the following in the modified dev.off:
>
> 1) Get the filename of the pdf device
> 2) close the device by calling the original dev.off()
> 3) compress the pdf file with a system call of pdftk.
>
>
If you are the one who initiated the pdf device shouldn't you know the name
of the file? in that case just do something like:
my.dev.off <- function (file, which = dev.cur())
{
if (which == 1)
stop("cannot shut down device 1 (the null device)")
.Internal(dev.off(as.integer(which)))
#system call (or something similar)
system(paste('pdftk',file))
dev.cur()
}
fn <- 'myplot.pdf'
pdf(fn)
#plot stuff
my.dev.off(fn)
-Cameron
--
View this message in context: http://www.nabble.com/Getting-file-name-from-pdf-device--tp24755915p24761759.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list