Skip to content

Commit

Permalink
feat: add unit (in, cm, mm) argument in function page_size()
Browse files Browse the repository at this point in the history
fix #579
  • Loading branch information
davidgohel committed Aug 14, 2024
1 parent 96d5196 commit 626f18f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: officer
Title: Manipulation of Microsoft Word and PowerPoint Documents
Version: 0.6.7.003
Version: 0.6.7.004
Authors@R: c(
person("David", "Gohel", , "[email protected]", role = c("aut", "cre")),
person("Stefan", "Moog", , "[email protected]", role = "aut"),
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

- new convenience functions `body_replace_gg_at_bkm()` and `body_replace_plot_at_bkm()`
to replace text content enclosed in a bookmark with a ggplot or a base plot.

- add `unit` (in, cm, mm) argument in function `page_size()`.

# officer 0.6.6

Expand Down
7 changes: 6 additions & 1 deletion R/ooxml_run_objects.R
Original file line number Diff line number Diff line change
Expand Up @@ -643,10 +643,15 @@ inch_to_tweep <- function(x) round(x * 72 * 20, digits = 0)
#' in landscape mode then the length becomes the width and the width becomes the length.
#' @param width,height page width, page height (in inches).
#' @param orient page orientation, either 'landscape', either 'portrait'.
#' @param unit unit for width and height, one of "in", "cm", "mm".
#' @examples
#' page_size(orient = "landscape")
#' @family functions for section definition
page_size <- function(width = 21 / 2.54, height = 29.7 / 2.54, orient = "portrait") {
page_size <- function(width = 21 / 2.54, height = 29.7 / 2.54, orient = "portrait", unit = "in") {

width <- convin(unit = unit, x = width)
height <- convin(unit = unit, x = height)

if (orient %in% "portrait") {
h <- max(c(height, width))
w <- min(c(height, width))
Expand Down
9 changes: 8 additions & 1 deletion man/page_size.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 626f18f

Please sign in to comment.