addDocument: Add an external document into a document object

Description Usage Arguments Details Value See Also Examples

View source: R/addDocument.R

Description

Add an external document into a document object

Usage

1
2
3
4
addDocument(doc, filename, ...)

## S3 method for class 'docx'
addDocument(doc, filename, ...)

Arguments

doc

document object

filename

"character" value, complete filename of the external file

...

further arguments passed to other methods

Details

ReporteRs does only copy the document as an external file. Headers and footers are also imported and displayed. This function is not to be used to merge documents.

Value

a document object

See Also

docx

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
if( check_valid_java_version() ){
doc.filename <- "addDocument_example.docx"
# set default font size to 10
options( "ReporteRs-fontsize" = 10 )

doc2embed <- docx( )
img.file <- file.path( Sys.getenv("R_HOME"),
                      "doc", "html", "logo.jpg" )
if( file.exists(img.file) && requireNamespace("jpeg", quietly = TRUE) ){
  dims <- attr( jpeg::readJPEG(img.file), "dim" )

  doc2embed <- addImage(doc2embed, img.file,
                       width = dims[2]/72, height = dims[1]/72)
  writeDoc( doc2embed, file = "external_file.docx" )

  doc <- docx( )
  doc <- addDocument( doc, filename = "external_file.docx" )
  writeDoc( doc, file = doc.filename )
}
}

davidgohel/ReporteRs documentation built on Dec. 4, 2018, 5:10 p.m.