Description Usage Arguments Details Value See Also Examples
Add a paragraph into a document object
1 2 3 4 5 6 7 8 9 | addParagraph(doc, value, ...)
## S3 method for class 'docx'
addParagraph(doc, value, stylename, bookmark,
par.properties = parProperties(), restart.numbering = FALSE, ...)
## S3 method for class 'pptx'
addParagraph(doc, value, offx, offy, width, height,
par.properties, append = FALSE, restart.numbering = FALSE, ...)
|
doc |
document object |
value |
text to add to the document as paragraphs:
an object of class |
... |
further arguments passed to other methods |
stylename |
value of the named style to apply to paragraphs in the docx document.
Expected value is an existing stylename of the template document used to create the
|
bookmark |
a character value ; id of the Word bookmark to replace by the table. optional. |
par.properties |
|
restart.numbering |
boolean value. If |
offx |
optional, x position of the shape (top left position of the bounding box) in inches. See details. |
offy |
optional, y position of the shape (top left position of the bounding box) in inches. See details. |
width |
optional, width of the shape in inches. See details. |
height |
optional, height of the shape in inches. See details. |
append |
boolean default to FALSE. If TRUE, paragraphs will be
appened in the current shape instead of beeing sent into a new shape.
Paragraphs can only be appended on shape containing paragraphs (i.e. you
can not add paragraphs after a FlexTable). Applies to only |
a paragraph is a set of text that ends with an end of line.
Read pot
to see how to get different font formats.
If an end of line is required, a new paragraph is required.
When document is a pptx
object, two positioning methods are available.
If arguments offx, offy, width, height are missing, position and dimensions
will be defined by the width and height of the next available shape of the slide. This
dimensions can be defined in the layout of the PowerPoint template used to create
the pptx
object.
If arguments offx, offy, width, height are provided, they become position and dimensions of the new shape.
Also, when document is a pptx
object,
shading and border settings of argument par.properties
will have no effect.
Argument par.properties is only used when value is a pot
or a set_of_paragraphs
.
If character values are used to fill slides, parameter append
will be ignored.
a document object
docx
, pptx
,
pot
, textProperties
,
parProperties
, list.settings
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | # define some text
sometext <- c( "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"In sit amet ipsum tellus. Vivamus dignissim arcu sit amet faucibus auctor.",
"Quisque dictum tristique ligula.")
# "My tailor is rich" with formatting on some words
pot1 <- pot("My tailor", textProperties(color = "red" ) ) +
" is " + pot("rich", textProperties(shading.color = "red",
font.weight = "bold" ) )
# "Cats and dogs" with formatting on some words
pot2 = pot("Cats", textProperties(color = "red" ) ) +
" and " +
pot("dogs", textProperties( color = "blue" ),
hyperlink = "http://www.wikipedia.org/" )
# create a set of paragraphs made of pot1 and pot2
my.pars <- set_of_paragraphs( pot1, pot2 )
# docx example ---------
if( check_valid_java_version() ){
doc.filename = "ex_paragraph.docx"
doc <- docx()
styles(doc)
doc <- addTitle( doc, "Title example 1", level = 1 )
# Add "Hello World" into the document doc
doc <- addParagraph(doc, "Hello Word", stylename = "Normal" )
doc <- addTitle( doc, "Title example 2", level = 1 )
# add sometext with stylename BulletList
doc <- addParagraph( doc, value = sometext, stylename="BulletList" )
doc <- addTitle( doc, "Title example 3", level = 1 )
doc <- addParagraph( doc, value = my.pars, par.properties = parCenter() )
writeDoc( doc, file = doc.filename )
}
if( check_valid_java_version() ){
# pptx example -------
# pptx example -------
doc.filename = "ex_paragraph.pptx"
doc <- pptx()
doc <- addSlide(doc, "Title and Content")
# Add "Hello World" into the document doc
doc <- addParagraph(doc, "Hello Word" )
doc <- addSlide(doc, "Title and Content")
doc <- addParagraph( doc, value = my.pars )
# Add my.pars into the document doc
doc <- addParagraph(doc, my.pars, offx = 3, offy = 3,
width = 2, height = 0.5,
par.properties=parProperties(text.align="center", padding=0) )
doc <- addSlide(doc, "Title and Content")
# Add my.pars into the document doc
doc <- addParagraph(doc, my.pars,
par.properties=parProperties(text.align="center", padding=24) )
writeDoc( doc, file = doc.filename )
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.