Creation of the object representing an
RTF document which can then receive contents with
the rtf_add() function and be written to a file with
the print(x, target="doc.rtf") function.
rtf_doc(
def_sec = prop_section(),
normal_par = fp_par(),
normal_chunk = fp_text(font.family = "Arial", font.size = 11)
)an object of class rtf representing an
empty RTF document.
a prop_section object used to define the default section
(page size, margins, header / footer, columns) applied to content added
before any explicit block_section().
an object generated by fp_par()
an object generated by fp_text()
rtf_doc() registers four paragraph styles: "Normal" (built from
normal_par / normal_chunk) and "heading 1" / "heading 2" /
"heading 3" (bold, dark blue shades, with outline levels so the
paragraphs feed Word's navigation pane and TOC field). The heading
names mirror Word's own convention so a script that adds paragraphs
with style = "heading 1" works identically against Word output
(body_add_par(..., style = "heading 1")) and RTF output
(rtf_add(..., style = "heading 1")).
To override a built-in look (size, color, spacing, outline level),
call rtf_set_paragraph_style() after rtf_doc() with the same
style_id.
doc <- rtf_doc()
doc <- rtf_set_paragraph_style(
doc,
style_id = "heading 1",
fp_p = fp_par(text.align = "center", padding = 12),
fp_t = fp_text_lite(bold = TRUE, font.size = 24, color = "#000000"),
outline_level = 1L
)
Use rtf_styles_info() to inspect the current style table.
read_docx(), print.rtf(), rtf_add(). See ?rtf_add for a
complete multi-section example exercising def_sec, headers / footers
and several block_section() calls.
rtf_doc(normal_par = fp_par(padding = 3))
Run the code above in your browser using DataLab