Provides a simple method to get text from a docx document. It returns a character vector containing all chunk of text found in the document.

text_extract(x, body = TRUE, header = TRUE, footer = TRUE, bookmark)

Arguments

x

docx object

body

specifies to scan document body

header

specifies to scan document header

footer

specifies to scan document footer

bookmark

a character value ; id of the Word bookmark to scan.

Value

a character vector

See also

docx, list_bookmarks

Examples

doc <- docx( title = "My example", template = file.path( system.file(package = "ReporteRs"), "templates/bookmark_example.docx") ) text_extract( doc )
#> [1] "My" " rep" "ort" #> [4] "PLOT" "Illud" " " #> [7] "tamen" " " "clausos" #> [10] " " "vehementer" " " #> [13] "angebat" " quod " "captis" #> [16] " " "navigiis" ", " #> [19] "quae" " " "frumenta" #> [22] " " "vehebant" " per " #> [25] "flumen" ", " "Isauri" #> [28] " " "quidem" " " #> [31] "alimentorum" " " "copiis" #> [34] " " "adfluebant" ", " #> [37] "ipsi" " " "vero" #> [40] " " "solitarum" " " #> [43] "rerum" " " "cibos" #> [46] " " "iam" " " #> [49] "consumendo" " " "inediae" #> [52] " " "propinquantis" " " #> [55] "aerumnas" " " "exitialis" #> [58] " " "horrebant" "." #> [61] "Illud" " " "tamen" #> [64] " " "clausos" " " #> [67] "vehementer" " " "angebat" #> [70] " quod " "captis" " " #> [73] "navigiis" ", " "quae" #> [76] " " "frumenta" " " #> [79] "vehebant" " per " "flumen" #> [82] ", " "Isauri" " " #> [85] "quidem" " " "alimentorum" #> [88] " " "copiis" " " #> [91] "adfluebant" ", " "ipsi" #> [94] " " "vero" " " #> [97] "solitarum" " " "rerum" #> [100] " " "cibos" " " #> [103] "iam" " " "consumendo" #> [106] " " "inediae" " " #> [109] "propinquantis" " " "aerumnas" #> [112] " " "exitialis" " " #> [115] "horrebant" "." "Below" #> [118] " a table" "Illud" " " #> [121] "tamen" " " "clausos" #> [124] " " "vehementer" " " #> [127] "angebat" " quod " "captis" #> [130] " " "navigiis" ", " #> [133] "quae" " " "frumenta" #> [136] " " "vehebant" " per " #> [139] "flumen" ", " "Isauri" #> [142] " " "quidem" " " #> [145] "alimentorum" " " "copiis" #> [148] " " "adfluebant" ", " #> [151] "ipsi" " " "vero" #> [154] " " "solitarum" " " #> [157] "rerum" " " "cibos" #> [160] " " "iam" " " #> [163] "consumendo" " " "inediae" #> [166] " " "propinquantis" " " #> [169] "aerumnas" " " "exitialis" #> [172] " " "horrebant" "." #> [175] "Authors" "Reviewers" "AUTHOR" #> [178] "REVIEWER" "PAGE \\* MERGEFORMAT" "1"
text_extract( doc, header = FALSE, footer = FALSE )
#> [1] "My" " rep" "ort" "PLOT" #> [5] "Illud" " " "tamen" " " #> [9] "clausos" " " "vehementer" " " #> [13] "angebat" " quod " "captis" " " #> [17] "navigiis" ", " "quae" " " #> [21] "frumenta" " " "vehebant" " per " #> [25] "flumen" ", " "Isauri" " " #> [29] "quidem" " " "alimentorum" " " #> [33] "copiis" " " "adfluebant" ", " #> [37] "ipsi" " " "vero" " " #> [41] "solitarum" " " "rerum" " " #> [45] "cibos" " " "iam" " " #> [49] "consumendo" " " "inediae" " " #> [53] "propinquantis" " " "aerumnas" " " #> [57] "exitialis" " " "horrebant" "." #> [61] "Illud" " " "tamen" " " #> [65] "clausos" " " "vehementer" " " #> [69] "angebat" " quod " "captis" " " #> [73] "navigiis" ", " "quae" " " #> [77] "frumenta" " " "vehebant" " per " #> [81] "flumen" ", " "Isauri" " " #> [85] "quidem" " " "alimentorum" " " #> [89] "copiis" " " "adfluebant" ", " #> [93] "ipsi" " " "vero" " " #> [97] "solitarum" " " "rerum" " " #> [101] "cibos" " " "iam" " " #> [105] "consumendo" " " "inediae" " " #> [109] "propinquantis" " " "aerumnas" " " #> [113] "exitialis" " " "horrebant" "." #> [117] "Below" " a table" "Illud" " " #> [121] "tamen" " " "clausos" " " #> [125] "vehementer" " " "angebat" " quod " #> [129] "captis" " " "navigiis" ", " #> [133] "quae" " " "frumenta" " " #> [137] "vehebant" " per " "flumen" ", " #> [141] "Isauri" " " "quidem" " " #> [145] "alimentorum" " " "copiis" " " #> [149] "adfluebant" ", " "ipsi" " " #> [153] "vero" " " "solitarum" " " #> [157] "rerum" " " "cibos" " " #> [161] "iam" " " "consumendo" " " #> [165] "inediae" " " "propinquantis" " " #> [169] "aerumnas" " " "exitialis" " " #> [173] "horrebant" "."
text_extract( doc, bookmark = "author" )
#> [1] "AUTHOR"