[Rd] pdf default version
Prof Brian Ripley
ripley at stats.ox.ac.uk
Sat Sep 16 21:26:31 CEST 2006
On Fri, 15 Sep 2006, Marc Schwartz (via MN) wrote:
> On Fri, 2006-09-15 at 12:12 -0500, Kevin Wright wrote:
>> R has had the ability to generate pdfs with transparent colors for a
>> couple of years now using pdf(..., version="1.4").
I presume we are talking about translucency aka semitransparency (alpha
channel strictly between 0 and 1) here, introduced in R 2.0.0: support for
col="transparent" is much older.
>> By default, Sweave uses just 'pdf' (without version 1.4), so a hack is
>> needed when using Sweave to create pdfs with transparent colors. See
>> http://tolstoy.newcastle.edu.au/R/help/04/11/6655.html
>>
>> I would find my work process simpler if R defaulted to generating PDFs
>> using version="1.4". The help page for R's pdf command says there is
>> a risk of some older pdf viewers not being able to view newer PDFs.
>> Does anyone have a feeling for how big a risk this is? I tried for a
>> while to search google for pdf metadata and the distribution of pdf
>> documents of different versions, but could find nothing useful to
>> report.
>>
>> The PDF 1.4 specification appears to have been published in November, 2001.
Both C99 and Fortran 90 are older, and compilers for them are not yet
universally available. Many R users even use older OSes than that date.
Given Adobe's patchy support for non-popularist OSes, there are lots of
viewers from quite a while back out there (I found Acroread 4.05 on one of
our systems without looking very hard). According to Distiller, PDF 1.4
was introduced in Acrobat 5, and 1.3 is still recommended as the lowest
common denominator.
>> Is updating pdf() to version="1.4" feasible?
In what sense: it does support that as an option? As the default, no.
>> Discussions on this topic will be watched with interest.
>>
>> Kevin Wright
>
> Rather than globally changing R, wouldn't it be better to add another
> option to Sweave?
>
> For example, one can already specify 'height' and 'width' arguments for
> figures, why not a pdf version value?
>
> If I am reading it correctly, the relevant code from Sweave.R seems to
> be within the RweaveLatexRuncode() function:
>
> if(options$pdf){
> pdf(file=paste(chunkprefix, "pdf", sep="."),
> width=options$width, height=options$height)
>
> Could this not be modified to something like:
>
> if(options$pdf){
> pdf(file=paste(chunkprefix, "pdf", sep="."),
> width=options$width, height=options$height,
> version = pdf.version)
>
> Then the call within the .Rnw file could be something like:
>
> <<fig=true,width=6,height=4,pdf.version=1.4,include=false>>=
or even
\SweaveOpts{echo=FALSE, pdf.version=1.4}
> I am presuming that I am oversimplifying the changes here as I have not
> looked at the other code that would be affected by this change.
You would need to set a default value, and that's non-trivial due to lack
of documentation of Sweave options (the internals need to be told that the
option is NOLOG (non-logical) and not numeric).
> Comments?
That seems a much better approach, and I've added it for 2.4.0.
Howver, I think the ideal solution is for the driver to keep track
of the features used and set the version number accordingly. I am not
sure why Paul did not do it that way (PDF viewers are supposed to ignore
non-conformant features), as if you use semitransparent colours you would
presumably like to see them where possible. Also implemented for 2.4.0,
but with a warning that setting pdf(version=1.4) will suppress.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-devel
mailing list