On Fri, Jul 31, 2009 at 8:49 AM, Rainer M Krug<r.m.k...@gmail.com> wrote:
> My question: how can I get the filename of the pdf from the device
> before it is closed?

I've also looked for this and couldn't find a way. I had a similar
use, where I wanted to get an R transcript with embedded plots in
emacs (see prettyR for another transcript-with-plots option). What I
did was use dev2bitmap to write out a PNG file. You could do something
similar with dev.copy2pdf to create the pdf after you do the plotting.
You could also use dev2bitmap in this manner to drive ghostscript to
create pdf's for you (I don't know if it'll compress like you want).
Here's what I did:

show <- function(file = paste(tempfile(), ".png", sep = "")) {
    dev2bitmap(file)
    cat("[[", file, "]]\n", sep = "") # I do some post-processing in
emacs to see the embedded graphic
}

My use case was that plots would be inserted where I used "show" as follows:

plot(sin)
show()    # <---- plot inserted into transcript here
plot(cos)
show("cos.png") # this time, a named local file instead of a temp file

- Tom

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to