This repository has been archived by the owner on Mar 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
accb9d8
commit 377be1e
Showing
5 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#' @title Simple Text Extraction From a Word Document | ||
#' | ||
#' @description | ||
#' Provides a simple method to get text from a docx document. | ||
#' It returns a \code{character} vector containing all | ||
#' chunk of text found in the document. | ||
#' @param x \code{\link{docx}} object | ||
#' @param body specifies to scan document body | ||
#' @param header specifies to scan document header | ||
#' @param footer specifies to scan document footer | ||
#' @param bookmark a character value ; id of the Word bookmark to scan. | ||
#' @return a character vector | ||
#' @examples | ||
#' #START_TAG_TEST | ||
#' doc = docx( title = "My example", template = file.path( | ||
#' find.package("ReporteRs"), "templates/bookmark_example.docx") ) | ||
#' text_extract( doc ) | ||
#' text_extract( doc, header = FALSE, footer = FALSE ) | ||
#' text_extract( doc, bookmark = "author" ) | ||
#' @example examples/STOP_TAG_TEST.R | ||
#' @seealso \code{\link{docx}} | ||
#' @export | ||
text_extract = function( x, body = TRUE, header = TRUE, footer = TRUE, bookmark){ | ||
if( missing( bookmark ) ) | ||
out = .jcall(x$obj, "[S", "getWords", body, header, footer) | ||
else { | ||
if( length( bookmark ) != 1 || !is.character(bookmark)) | ||
stop("bookmark must be an atomic character.") | ||
out = .jcall(x$obj, "[S", "getWords", casefold( bookmark, upper = FALSE ) ) | ||
} | ||
out | ||
} |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
% Generated by roxygen2 (4.1.0): do not edit by hand | ||
% Please edit documentation in R/text_extract.R | ||
\name{text_extract} | ||
\alias{text_extract} | ||
\title{Simple text extraction from a docx document} | ||
\usage{ | ||
text_extract(x, body = TRUE, header = TRUE, footer = TRUE, bookmark) | ||
} | ||
\arguments{ | ||
\item{x}{\code{\link{docx}} object} | ||
|
||
\item{body}{specifies to scan document body} | ||
|
||
\item{header}{specifies to scan document header} | ||
|
||
\item{footer}{specifies to scan document footer} | ||
|
||
\item{bookmark}{a character value ; id of the Word bookmark to scan.} | ||
} | ||
\value{ | ||
a character vector | ||
} | ||
\description{ | ||
Provides a simple method to get text from a docx document. | ||
It returns a \code{character} vector containing all | ||
chunk of text found in the document. | ||
} | ||
\examples{ | ||
#START_TAG_TEST | ||
doc = docx( title = "My example", template = file.path( | ||
find.package("ReporteRs"), "templates/bookmark_example.docx") ) | ||
text_extract( doc ) | ||
text_extract( doc, header = FALSE, footer = FALSE ) | ||
text_extract( doc, bookmark = "author" ) | ||
#STOP_TAG_TEST | ||
} | ||
\seealso{ | ||
\code{\link{docx}} | ||
} | ||
|