@@ -170,10 +170,7 @@ setMethod(
170170 stop(" The text argument is not a character string." )
171171 }
172172
173- if (
174- ! (is.null(mch ) ||
175- (inherits(mch , " numeric" ) && length(mch ) == 1 ) && mch > 0 )
176- ) {
173+ if (! (is.null(mch ) || (inherits(mch , " numeric" ) && length(mch ) == 1 ) && mch > 0 )) {
177174 stop(" The mch argument is not a positive numeric value." )
178175 }
179176
@@ -1007,40 +1004,116 @@ setMethod("show", "gridifyLayout", function(object) {
10071004# ' set_cell("footer_right", "Page xx of nn") %>%
10081005# ' set_cell("watermark", "DRAFT")
10091006# '
1010- # ' \dontrun{
1011- # ' export_to(gridify_obj, to = "output.png")
1012- # ' export_to(gridify_obj, to = "output.png", width = 2400, height = 1800, res = 300)
1007+ # ' # Export a result to different file types
1008+ # '
1009+ # ' # Different file export formats require specific capabilities in your R installation.
1010+ # ' # Use capabilities() to check which formats are supported in your R build.
10131011# '
1014- # ' export_to(gridify_obj, to = "output.jpeg")
1015- # ' export_to(gridify_obj, to = "output.jpeg", width = 2400, height = 1800, res = 300)
1012+ # ' # PNG
1013+ # ' temp_png_default <- tempfile(fileext = ".png")
1014+ # ' export_to(
1015+ # ' gridify_obj,
1016+ # ' to = temp_png_default
1017+ # ' )
10161018# '
1017- # ' export_to(gridify_obj, to = "output.tiff")
1018- # ' export_to(gridify_obj, to = "output.tiff", width = 2400, height = 1800, res = 300)
1019+ # ' temp_png_custom <- tempfile(fileext = ".png")
1020+ # ' export_to(
1021+ # ' gridify_obj,
1022+ # ' to = temp_png_custom,
1023+ # ' width = 2400,
1024+ # ' height = 1800,
1025+ # ' res = 300
1026+ # ' )
10191027# '
1020- # ' export_to(gridify_obj, to = "outputA4.pdf")
1021- # ' export_to(gridify_obj, to = "outputA4long.pdf", width = 8.3, height = 11.7)
1028+ # ' # JPEG
1029+ # ' temp_jpeg_default <- tempfile(fileext = ".jpeg")
1030+ # ' export_to(
1031+ # ' gridify_obj,
1032+ # ' to = temp_jpeg_default
1033+ # ' )
10221034# '
1023- # ' # Use different pdf device
1035+ # ' temp_jpeg_custom <- tempfile(fileext = ".jpeg")
10241036# ' export_to(
10251037# ' gridify_obj,
1026- # ' to = "outputA4long.pdf", device = grDevices::cairo_pdf, width = 8.3, height = 11.7
1038+ # ' to = temp_jpeg_custom,
1039+ # ' width = 2400,
1040+ # ' height = 1800,
1041+ # ' res = 300
10271042# ' )
10281043# '
1044+ # ' # TIFF
1045+ # ' temp_tiff_default <- tempfile(fileext = ".tiff")
1046+ # ' export_to(
1047+ # ' gridify_obj,
1048+ # ' to = temp_tiff_default
1049+ # ' )
1050+ # '
1051+ # ' temp_tiff_custom <- tempfile(fileext = ".tiff")
1052+ # ' export_to(
1053+ # ' gridify_obj,
1054+ # ' to = temp_tiff_custom,
1055+ # ' width = 2400,
1056+ # ' height = 1800,
1057+ # ' res = 300
1058+ # ' )
1059+ # '
1060+ # ' # PDF
1061+ # ' temp_pdf_A4 <- tempfile(fileext = ".pdf")
1062+ # ' export_to(
1063+ # ' gridify_obj,
1064+ # ' to = temp_pdf_A4
1065+ # ' )
1066+ # '
1067+ # ' temp_pdf_A4long <- tempfile(fileext = ".pdf")
1068+ # ' export_to(
1069+ # ' gridify_obj,
1070+ # ' to = temp_pdf_A4long,
1071+ # ' width = 8.3,
1072+ # ' height = 11.7
1073+ # ' )
1074+ # '
1075+ # ' # Use different pdf device - cairo_pdf
1076+ # ' temp_pdf_A4long_cairo <- tempfile(fileext = ".pdf")
1077+ # ' export_to(
1078+ # ' gridify_obj,
1079+ # ' to = temp_pdf_A4long_cairo,
1080+ # ' device = grDevices::cairo_pdf,
1081+ # ' width = 8.3,
1082+ # ' height = 11.7
1083+ # ' )
1084+ # '
1085+ # ' # Multiple Objects - a list
1086+ # '
10291087# ' gridify_list <- list(gridify_obj, gridify_obj)
10301088# '
1031- # ' export_to(gridify_list, to = "multipageA4.pdf")
1032- # ' export_to(gridify_list, to = "multipageA4long.pdf", width = 8.3, height = 11.7)
1033- # ' export_to(gridify_list, to = "multipageA4long.pdf", width = 8.3, height = 11.7)
1089+ # ' temp_pdf_multipageA4 <- tempfile(fileext = ".pdf")
1090+ # ' export_to(
1091+ # ' gridify_list,
1092+ # ' to = temp_pdf_multipageA4
1093+ # ' )
1094+ # '
1095+ # ' temp_pdf_multipageA4long <- tempfile(fileext = ".pdf")
1096+ # ' export_to(
1097+ # ' gridify_list,
1098+ # ' to = temp_pdf_multipageA4long,
1099+ # ' width = 8.3,
1100+ # ' height = 11.7
1101+ # ' )
10341102# '
1035- # ' export_to(gridify_list, to = c("page1 .png", "page2 .png"))
1103+ # ' temp_png_multi <- c(tempfile(fileext = " .png"), tempfile(fileext = " .png"))
10361104# ' export_to(
10371105# ' gridify_list,
1038- # ' to = c("page1_96res.png", "page2_96res.png"),
1106+ # ' to = temp_png_multi
1107+ # ' )
1108+ # '
1109+ # ' temp_png_multi_custom <- c(tempfile(fileext = ".png"), tempfile(fileext = ".png"))
1110+ # ' export_to(
1111+ # ' gridify_list,
1112+ # ' to = temp_png_multi_custom,
10391113# ' width = 800,
10401114# ' height = 600,
10411115# ' res = 96
10421116# ' )
1043- # ' }
10441117# '
10451118# ' @export
10461119setGeneric ("export_to ", function(x, to, device = NULL, ...) {
0 commit comments