body_add_img_autofit: add an image into an rdocx object, with autofiting of width...

Description Usage Arguments Value Author(s) Examples

View source: R/officer.r

Description

add an image into an rdocx object, with autofiting of width and height

Usage

1
2
body_add_img_autofit(x, src, style = NULL, pos = "after",
  landscape = FALSE)

Arguments

x

the rdocx object (created with the read_docx function of officer package)

src

image filename, the basename of the file must not contain any blank

style

paragraph style

pos

where to add the new element relative to the cursor, one of "after", "before", "on"

landscape

is the image inserted in a landscape section? (default: FALSE)

Value

a new rdocx object

Author(s)

David Hajage

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
## Not run: 
library(biostat2)
library(officer)

jpeg("carre.jpg", width = 300, height = 300)
plot(1)
dev.off()
jpeg("long.jpg", width = 300, height = 600)
plot(1)
dev.off()
jpeg("large.jpg", width = 600, height = 300)
plot(1)
dev.off()

doc <- read_docx()
doc <- body_add_img_autofit(doc, "carre.jpg")
doc <- body_add_img_autofit(doc, "long.jpg") 
doc <- body_add_img_autofit(doc, "large.jpg") 
doc <- body_end_section_portrait(doc)

doc <- body_add_img_autofit(doc, "carre.jpg", landscape = TRUE) 
doc <- body_add_img_autofit(doc, "long.jpg", landscape = TRUE) 
doc <- body_add_img_autofit(doc, "large.jpg", landscape = TRUE) 
doc <- body_end_section_landscape(doc)

print(doc, target = "toto.docx")

## End(Not run)

eusebe/biostat2 documentation built on Dec. 27, 2019, 4:22 p.m.