Description Usage Arguments Value Author(s) Examples
add an image into an rdocx object, with autofiting of width and height
1 2  | body_add_img_autofit(x, src, style = NULL, pos = "after",
  landscape = FALSE)
 | 
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)  | 
a new rdocx object
David Hajage
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)
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.