From 7517eb0ed1a66488b937c039d4bcadefeff6b479 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Sat, 8 Oct 2016 03:07:50 +0200 Subject: Add a method to write cropped pdf files --- R/chent.R | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'R') diff --git a/R/chent.R b/R/chent.R index dd51798..b2a1da6 100644 --- a/R/chent.R +++ b/R/chent.R @@ -241,6 +241,20 @@ chent <- R6Class("chent", } if (!exists(to, self$TPs)) stop(to, " was not found in TPs") self$ff[i, ] <- c(from, to, ff, comment, pages) + }, + pdf = function(file = paste0(self$identifier, ".pdf"), dir = "structures") { + if (!dir.exists("structures")) { + message("Directory '", dir, "' does not exist") + message("Creating directory '", dir, "'") + dir.create(dir) + } + path = file.path(dir, file) + message("Creating file '", path, "'") + pdf(path) + plot(self) + dev.off() + message("Cropping file '", path, "' using pdfcrop") + system(paste("pdfcrop --margin 10", path, path, "> /dev/null")) } ) ) -- cgit v1.2.1