15

I am using RStudio for package development in windows environment. I need to enable pdf vignette compression to avoid 'gs+qpdf' made some significant size reductions: warning.

I have added --compact-vignettes="gs+qpdf" as additional options to Project Options : Build Tools > Build Source Package, but there is no change in the size of pdf vignette in the source package built using devtools::build().

I have also added to the YAML header in the vignette latex compression options as follows.

header-includes:
- \pdfminorversion=5
- \pdfcompresslevel=9
- \pdfobjcompresslevel=2

Still there is no change.

However I am getting the desired compression while using tools::compactPDF with gs_cmd = Sys.getenv("R_GSCMD") and gs_quality = "ebook arguments.

How to get the desired compression while building packages for avoiding the warning?

Crops
  • 5,024
  • 5
  • 38
  • 65

1 Answers1

9

I've found, for some reason (perhaps related to the quotes?), that RStudio doesn't like the --compact-vignettes="gs+qpdf".

Instead, I used --compact-vignettes=both, which did the trick for me, when using RStudio's "Build" panel.

From the command line, you'd need to type devtools::build(args = c('--compact-vignettes=both')). (For versions of devtools < 2.2.2, replace args with build_args.)

https://support.rstudio.com/hc/en-us/articles/200486518-Customizing-Package-Build-Options has more details.

Martin Smith
  • 3,687
  • 1
  • 24
  • 51
  • 1
    As of `devtools` version 2.4.5, the correct usage is `devtools::build(args = c('--compact-vignettes=both'))`. Notice that it is now args and no longer build_args. – iembry Dec 23 '22 at 19:22