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 66 67 68 69 70 71 72 73 74 75 76
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tools.R
\name{pdftools}
\alias{pdftools}
\alias{pdf_info}
\alias{pdf_text}
\alias{pdf_data}
\alias{pdf_fonts}
\alias{pdf_attachments}
\alias{pdf_toc}
\alias{pdf_pagesize}
\title{PDF utilities}
\usage{
pdf_info(pdf, opw = "", upw = "")
pdf_text(pdf, opw = "", upw = "", raw = FALSE)
pdf_data(pdf, font_info = FALSE, opw = "", upw = "")
pdf_fonts(pdf, opw = "", upw = "")
pdf_attachments(pdf, opw = "", upw = "")
pdf_toc(pdf, opw = "", upw = "")
pdf_pagesize(pdf, opw = "", upw = "")
}
\arguments{
\item{pdf}{file path or raw vector with pdf data}
\item{opw}{string with owner password to open pdf}
\item{upw}{string with user password to open pdf}
\item{raw}{return text in raw stream order. Default is to use physical layout order.}
\item{font_info}{if TRUE, extract font-data for each box. Be careful, this
requires a very recent version of poppler and will error otherwise.}
}
\description{
Utilities based on libpoppler for extracting text, fonts, attachments
and metadata from a pdf file.
}
\details{
The \code{\link{pdf_text}} function renders all textboxes on a text canvas
and returns a character vector of equal length to the number of pages in the
PDF file. On the other hand, \code{\link{pdf_data}} is more low level and
returns one data frame per page, containing one row for each textbox in the PDF.
Note that \code{\link{pdf_data}} requires a recent version of libpoppler
which might not be available on all Linux systems.
When using \code{\link{pdf_data}} in R packages, condition use on
\code{poppler_config()$has_pdf_data} which shows if this function can be
used on the current system. For Ubuntu 16.04 (Xenial) and 18.04 (Bionic)
you can use \href{https://github.com/ropensci/pdftools#installation}{the PPA}
with backports of Poppler 0.74.0.
Poppler is pretty verbose when encountering minor errors in PDF files,
in especially \code{\link{pdf_text}}. These messages are usually safe
to ignore, use \code{\link{suppressMessages}} to hide them altogether.
}
\examples{
# Just a random pdf file
pdf_file <- file.path(R.home("doc"), "NEWS.pdf")
info <- pdf_info(pdf_file)
text <- pdf_text(pdf_file)
fonts <- pdf_fonts(pdf_file)
files <- pdf_attachments(pdf_file)
}
\seealso{
Other pdftools:
\code{\link{pdf_ocr_text}()},
\code{\link{qpdf}},
\code{\link{rendering}}
}
\concept{pdftools}
|