pdf_crop | R Documentation |
Remove whitespace margins using https://ctan.org/pkg/pdfcrop and
optionally embed fonts using grDevices::embedFonts()
. You may install
pdfcrop
using TinyTeX (https://cran.r-project.org/package=tinytex) with
tinytex::tlmgr_install('pdfcrop')
.
pdf_crop(
filename,
mustWork = FALSE,
pdfcrop = Sys.which("pdfcrop"),
embed_fonts = FALSE
)
filename |
Filename of a PDF file to crop. The file will be overwritten. |
mustWork |
If |
pdfcrop |
Path to the |
embed_fonts |
( |
You may also wish to consider extrafont::embed_fonts()
(https://cran.r-project.org/package=extrafont).
library(extrafont) # If you need to specify the path to Ghostscript (probably not needed in Linux) Sys.setenv(R_GSCMD = "C:/Program Files/gs/gs9.56.1/bin/gswin64c.exe") embed_fonts("original.pdf", outfile = "new.pdf")
As an alternative, saving the PDF with grDevices::cairo_pdf()
should
already embed the fonts.
Nothing
grDevices::embedFonts()
extrafont::embed_fonts()
grDevices::cairo_pdf()
## Not run:
extdata_path <- system.file(package = "eaf", "extdata")
A1 <- read_datasets(file.path(extdata_path, "wrots_l100w10_dat"))
A2 <- read_datasets(file.path(extdata_path, "wrots_l10w100_dat"))
pdf(file = "eaf.pdf", onefile = TRUE, width = 5, height = 4)
eafplot(list(A1 = A1, A2 = A2), percentiles = 50, sci.notation=TRUE)
dev.off()
pdf_crop("eaf.pdf")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.