The R Project SVN R

Rev

Rev 88908 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 88908 Rev 90182
Line 27... Line 27...
27
  \item{paths}{A character vector of paths to PDF files, or a length-one
27
  \item{paths}{A character vector of paths to PDF files, or a length-one
28
    character vector naming a directory, when all \file{.pdf} files in
28
    character vector naming a directory, when all \file{.pdf} files in
29
    that directory will be used.}
29
    that directory will be used.}
30
  \item{qpdf}{Character string giving the path to the \command{qpdf}
30
  \item{qpdf}{Character string giving the path to the \command{qpdf}
31
    command.  If empty, \command{qpdf} will not be used.}
31
    command.  If empty, \command{qpdf} will not be used.}
32
  \item{gs_cmd}{Character string giving the path to the \I{GhostScript}
32
  \item{gs_cmd}{Character string giving the path to the Ghostscript
33
    executable, if that is to be used.  On Windows this is the path to
33
    executable, if that is to be used.  On Windows this is the path to
34
    \file{gswin32c.exe} or \file{gswin64c.exe}.  If \code{""} (the
34
    \file{gswin32c.exe} or \file{gswin64c.exe}.  If \code{""} (the
35
    default), the function will try to find a platform-specific path to
35
    default), the function will try to find a platform-specific path to
36
    \I{GhostScript} where required.}
36
    Ghostscript where required.}
37
  \item{gs_quality}{A character string indicating the quality required:
37
  \item{gs_quality}{A character string indicating the quality required:
38
    the options are \code{"none"} (so \I{GhostScript} is not used),
38
    the options are \code{"none"} (so Ghostscript is not used),
39
    \code{"printer"} (300dpi), \code{"ebook"} (150dpi) and
39
    \code{"printer"} (300dpi), \code{"ebook"} (150dpi) and
40
    \code{"screen"} (72dpi).  Can be abbreviated.}
40
    \code{"screen"} (72dpi).  Can be abbreviated.}
41
  \item{gs_extras}{An optional character vector of further options to be
41
  \item{gs_extras}{An optional character vector of further options to be
42
    passed to \I{GhostScript}.}
42
    passed to Ghostscript.}
43
  \item{verbose}{\code{\link{logical}} or non-negative integer indicating if
43
  \item{verbose}{\code{\link{logical}} or non-negative integer indicating if
44
    and how much of the compression utilities' output should be shown.}
44
    and how much of the compression utilities' output should be shown.}
45
  %--> format(*):
45
  %--> format(*):
46
  \item{x}{An object of class \code{"compactPDF"}.}
46
  \item{x}{An object of class \code{"compactPDF"}.}
47
  \item{ratio, diff}{Limits for reporting: files are only reported whose
47
  \item{ratio, diff}{Limits for reporting: files are only reported whose
Line 51... Line 51...
51
}
51
}
52
\details{
52
\details{
53
  This by default makes use of \command{qpdf}, available from
53
  This by default makes use of \command{qpdf}, available from
54
  \url{https://qpdf.sourceforge.io/} (including as a Windows binary) and
54
  \url{https://qpdf.sourceforge.io/} (including as a Windows binary) and
55
  included with the CRAN macOS distribution of \R.  If \code{gs_cmd}
55
  included with the CRAN macOS distribution of \R.  If \code{gs_cmd}
56
  is non-empty and \code{gs_quality != "none"}, \I{GhostScript} will used
56
  is non-empty and \code{gs_quality != "none"}, Ghostscript will used
57
  first, then \command{qpdf} if it is available.  If
57
  first, then \command{qpdf} if it is available.  If
58
  \code{gs_quality != "none"} and \code{gs_cmd} is \code{""}, an attempt
58
  \code{gs_quality != "none"} and \code{gs_cmd} is \code{""}, an attempt
59
  will be made to find a \I{GhostScript} executable.
59
  will be made to find a Ghostscript executable.
60
 
60
 
61
  \command{qpdf} and/or \command{gs_cmd} are run on all PDF files found,
61
  \command{qpdf} and/or \command{gs_cmd} are run on all PDF files found,
62
  and those which are reduced in size by at least 10\% and 10Kb are
62
  and those which are reduced in size by at least 10\% and 10Kb are
63
  replaced.
63
  replaced.
64
 
64
 
65
  The strategy of our use of \command{qpdf} is to (losslessly) compress
65
  The strategy of our use of \command{qpdf} is to (losslessly) compress
66
  both PDF streams and objects.  \I{GhostScript} compresses streams and more
66
  both PDF streams and objects.  Ghostscript compresses streams and more
67
  (including downsampling and compressing embedded images) and
67
  (including downsampling and compressing embedded images) and
68
  consequently is much slower and may lose quality (but can also produce
68
  consequently is much slower and may lose quality (but can also produce
69
  much smaller PDF files).  However, quality \code{"ebook"} is perfectly
69
  much smaller PDF files).  However, quality \code{"ebook"} is perfectly
70
  adequate for screen viewing and printing on laser printers.
70
  adequate for screen viewing and printing on laser printers.
71
 
71
 
Line 74... Line 74...
74
  so this is very unlikely to cause difficulties.
74
  so this is very unlikely to cause difficulties.
75
 
75
 
76
  Stream compression is what most often has large gains.  Most PDF
76
  Stream compression is what most often has large gains.  Most PDF
77
  documents are generated with object compression, but this does not
77
  documents are generated with object compression, but this does not
78
  seem to be the default for \I{MiKTeX}'s \command{pdflatex}.  For some PDF
78
  seem to be the default for \I{MiKTeX}'s \command{pdflatex}.  For some PDF
79
  files (and especially package vignettes), using \I{GhostScript} can
79
  files (and especially package vignettes), using Ghostscript can
80
  dramatically reduce the space taken by embedded images (often
80
  dramatically reduce the space taken by embedded images (often
81
  screenshots).
81
  screenshots).
82
 
82
 
83
  Where both \I{GhostScript} and \command{qpdf} are selected (when
83
  Where both Ghostscript and \command{qpdf} are selected (when
84
  \code{gs_quality != "none"} and both executables are found), they are
84
  \code{gs_quality != "none"} and both executables are found), they are
85
  run in that order and the size reductions apply to the total
85
  run in that order and the size reductions apply to the total
86
  compression achieved.
86
  compression achieved.
87
}
87
}
88
 
88
 
Line 97... Line 97...
97
}
97
}
98
 
98
 
99
\note{
99
\note{
100
  The external tools used may change in future releases.
100
  The external tools used may change in future releases.
101
 
101
 
102
  Frequently, updates to \I{GhostScript} have produced better compression (up
102
  Frequently, updates to Ghostscript have produced better compression (up
103
  to several times better), so if possible use the latest version available.
103
  to several times better), so if possible use the latest version available.
104
}
104
}
105
 
105
 
106
\seealso{
106
\seealso{
107
  \code{\link{resaveRdaFiles}}.
107
  \code{\link{resaveRdaFiles}}.