R/pdfAnnotations.R

Defines functions pdfAnnotations

Documented in pdfAnnotations

pdfAnnotations <- function(file, type=c("Highlight", "Popup"), collapse=TRUE){
    type <- match.arg(type)
    commonjpod <- rJava:::.jnew("common/CommonRJPod")
    commonjpod$open(file)
    doc <- commonjpod$getDoc()
    anns <- doc$getAnnotations()
    annsArray <- anns$toArray()
    annsArray <- rJava:::.jevalArray(annsArray)
    types <- sapply(annsArray, function(x) x$getSubtypeLabel())
    idx <- types %in% "Highlight"
    annsArray <- annsArray[idx]
    ans <- sapply(annsArray, function(x) x$getContents())
    Encoding(ans) <- "UTF-8"
    commonjpod$close()
    if (collapse) ans <- paste(ans, collapse="\n\n")
    ans
}

Try the rjpod package in your browser

Any scripts or data that you put into this service are public.

rjpod documentation built on May 2, 2019, 4:54 p.m.