smallpdf.off: Close smallpdf device

Description Usage Arguments Value See Also Examples

Description

Closes smallpdf device and converts the files into. This is only worthwhile when the pdf has a lot of information, such as when using image.

Usage

1
2
smallpdf.off(pdfname, pdfobj = NULL, mypattern, dev,
  extra.opts = "-quality 100", outdir, clean = FALSE)

Arguments

pdfname

filename of PDF to be created

pdfobj

List with elements mypattern and dev, returned from smallpdf. If this is not NULL, overrides the mypattern and dev options.

mypattern

regular expression pattern for device files (from smallpdf)

dev

device used to open (from smallpdf)

extra.opts

Additional options sent to convert

outdir

Directory of intermediate bitmap files (defaults to tempdir())

clean

Delete temporary bitmap files or not?

Value

The command for the conversion

See Also

dev.off

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
## Not run: 
## not good for small plots
x = smallpdf(dev="jpeg")
dat = matrix(rnorm(1e3*4), ncol=4)
plot(dat[,1], dat[,2])
plot(dat[,3], dat[,4])
fname = file.path(tempdir(), "smallpdf.pdf")
smallpdf.off(pdfname = fname, mypattern=x$mypattern, dev=x$dev)
print(file.info(fname)$size)
# view.pdf(fname)
fname2 = file.path(tempdir(), "normalpdf.pdf")
pdf(fname2)
plot(dat[,1], dat[,2])
plot(dat[,3], dat[,4])
dev.off()
file.info(fname2)$size
print(file.info(fname2)$size / file.info(fname)$size)

## better for large plots
x = smallpdf(dev="jpeg")
dat = matrix(rnorm(1e6*4), ncol=4)
plot(dat[,1], dat[,2])
plot(dat[,3], dat[,4])
fname = file.path(tempdir(), "smallpdf.pdf")
smallpdf.off(pdfname = fname, mypattern=x$mypattern, dev=x$dev)
file.info(fname)$size
# [1] 3339399
# view.pdf(fname)
fname2 = file.path(tempdir(), "normalpdf.pdf")
pdf(fname2)
plot(dat[,1], dat[,2])
plot(dat[,3], dat[,4])
dev.off()
file.info(fname2)$size
# [1] 13648866
file.info(fname2)$size / file.info(fname)$size
# [1] 4.087222

## End(Not run)

muschellij2/smallpdf documentation built on May 23, 2019, 9:55 a.m.