[Rd] Failure to get compactPDF to compact a pdf file
Uwe Ligges
ligges at statistik.tu-dortmund.de
Wed Jan 25 11:19:49 CET 2012
On 24.01.2012 22:22, John Maindonald wrote:
> Quoting from the R-2.14.1 help page for compactPDF:
> "
> This by default makes use of 'qpdf', available from<URL:
> http://qpdf.sourceforge.net/> (including as a Windows binary) and
> included with the CRAN Mac OS X distribution of R. If 'gs_cmd' is
> non-empty, GhostScript will used instead.
> "
>
> The defaults are:
> compactPDF(paths, qpdf = Sys.getenv("R_QPDF", "qpdf"),
> gs_cmd = Sys.getenv("R_GSCMD", ""),
> gs_quality = c("printer", "ebook", "screen"),
> gs_extras = character())
>
>> Sys.getenv("R_QPDF", "qpdf")
> [1] "/Library/Frameworks/R.framework/Resources/bin/qpdf"
>> Sys.getenv("R_GSCMD", "")
> [1] ""
>>
>
> Thus, as far as I can see, compactPDF is set up (on my system) to use qpdf to compress.
>
> I take it then that the "Writing R Extensions manual [2.14.1 (2011-12-22)] is anticipating what is in R-devel:
> "
> The --compact-vignettes option will run tools::compactPDF over the PDF files in inst/doc (and its subdirectories) to losslessly compress them. This is not enabled by default (it can be selected by environment variable _R_BUILD_COMPACT_VIGNETTES_) and needs qpdf(http://qpdf.sourceforge.net/) to be available.
> "
No entirely: it was not anticipating that "--compact-vignettes=ps" is
possible in R-devel.
Best,
Uwe
> John Maindonald email: john.maindonald at anu.edu.au
> phone : +61 2 (6125)3473 fax : +61 2(6125)5549
> Centre for Mathematics& Its Applications, Room 1194,
> John Dedman Mathematical Sciences Building (Building 27)
> Australian National University, Canberra ACT 0200.
> http://www.maths.anu.edu.au/~johnm
>
> On 24/01/2012, at 11:22 PM, Prof Brian Ripley wrote:
>
>> On 24/01/2012 08:30, John Maindonald wrote:
>>> I am failing to get compactPDF to make any change to a pdf file
>>> that, a/c to the message from the CRAN upload site, can be very
>>> substantially compacted. Any ideas what may be wrong?
>>
>> AFAICS you are quoting a message from R-devel, which tries to find 'gs' for you. In R 2.14.1 you need to tell compactPDF where it is (assuming you do have it installed): see its help.
>>
>>> I have also tried recreating the pdf file. I also tried
>>> R CMD build --resave-data --compact-vignettes DAAG
>>
>> Again, in R-devel you can do R CMD build --compact-vignettes=gs (assuming that is in your path or R_GSCMD is set), but not in R 2.14.1.
>>
>> But I have already told you directly (and been ignored) that the problem is the excessive resolution of the embedded bitmap image which needs to be down-sampled.
>>
>>
>>> The data files compact alright (but I get the 'significantly better compression'
>>> warning message that might suggest that this is not happening), but the pdf
>>> file appears to go into the package unmodified.
>>>
>>> <<<<
>>>> tools::compactPDF('/Users/johnm/packages/DAAG/inst/doc/', gs_quality = "ebook")
>>>> dir('/Users/johnm/packages/DAAG/inst/doc/')
>>> [1] "rockArt.pdf"
>>>> sessionInfo()
>>> R version 2.14.1 (2011-12-22)
>>> Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
>>>
>>> locale:
>>> [1] C
>>>
>>> attached base packages:
>>> [1] stats graphics grDevices utils datasets methods base
>>>
>>> loaded via a namespace (and not attached):
>>> [1] tools_2.14.1
>>>>>>>
>>>
>>>> From the Unix command line:
>>> jhm:doc johnm$ ls -lt /Users/johnm/packages/DAAG/inst/doc
>>> total 1368
>>> -rw-r--r--@ 1 johnm staff 696762 2 Aug 12:35 rockArt.pdf
>>>
>>> Message from the CRAN upload site:
>>>
>>> * checking sizes of PDF files under ‘inst/doc’ ... NOTE
>>> ‘gs’ made some significant size reductions:
>>> compacted ‘rockArt.pdf’ from 680Kb to 58Kb
>>> consider running tools::compactPDF(gs_quality = "ebook") on these files
>>>
>>> John Maindonald email: john.maindonald at anu.edu.au
>>> phone : +61 2 (6125)3473 fax : +61 2(6125)5549
>>> Centre for Mathematics& Its Applications, Room 1194,
>>> John Dedman Mathematical Sciences Building (Building 27)
>>> Australian National University, Canberra ACT 0200.
>>> http://www.maths.anu.edu.au/~johnm
>>>
>>> ______________________________________________
>>> R-devel at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>>
>> --
>> 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
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
More information about the R-devel
mailing list