Karan Tibrewal
Karan Tibrewal

Reputation: 445

PDF to txt in R

I'm trying to convert a pdf to txt using pdftotxt. Keep getting an error. Would appreciate help:

dest <- getwd()

# make a vector of PDF file names
myfiles <- list.files(path = dest, pattern = "pdf",  full.names = TRUE)


lapply(myfiles, function(i) system(paste('"C:/Users/Karan       Tibrewal/Downloads/xpdfbin-win-3.04.zip/xpdfbin-win-3.04/bin32/pdftotxt.exe"', 
                                     paste0('"', i, '"')), wait = FALSE) )

I get this warning :

Warning message: running command '"C:/Users/Karan Tibrewal/Downloads/xpdfbin-win-3.04.zip/xpdfbin-win-3.04/bin64/pdftotxt.exe" "C:/Users/Karan Tibrewal/Documents/cem/12_13.pdf"' had status 127

I can't find the txt file. Whats wrong?

Upvotes: 0

Views: 990

Answers (2)

Atish Dukle
Atish Dukle

Reputation: 1

I think you are getting error because of spaces in the file path. Possible solution will be to use "Entire File Path" in double quotes. use messagebox and check whether your full path gets in double quotes.

Use this:

'"""C:/Users/Karan Tibrewal/Downloads/xpdfbin-win-3.04.zip/xpdfbin-win-3.04/bin32/pdftotxt.exe"""'

paste0('"""', i, '"""')

Upvotes: 0

BioProgram
BioProgram

Reputation: 704

I think you need a separator when there is a space in the path. Something like "\" instead of \ ? between Karan and Tibrewel?

Upvotes: 1

Related Questions