2013-08-06 67 views
1

我已經試過了example code recommended in the tm::readPDF documentation連接:TM readPDF:文件錯誤(CON,「R」):無法打開

library(tm) 

if(all(file.exists(Sys.which(c("pdfinfo", "pdftotext"))))) { 
    uri <- system.file(file.path("doc", "tm.pdf"), package = "tm") 
    pdf <- readPDF(PdftotextOptions = "-layout")(elem = list(uri = uri), 
               language = "en", 
               id = "id1") 
    pdf[1:13] 
} 

但我得到以下錯誤(其中調用由readPDF返回的功能後出現):

Error in file(con, "r") : cannot open the connection 
In addition: Warning message: 
In file(con, "r") : 
    cannot open file 'C:\DOCUME~1\Tomas\LOCALS~1\Temp\RtmpU33iWo\pdfinfo31c2bd5762a': No such file or directory 

請注意,我已經安裝了所有的xpdf二進制文件的當前目錄(但這是由if條件處理)。

編輯:發現這是一個錯誤。什麼是最簡單的解決方法?

+0

簡單的解決方法:http://stackoverflow.com/questions/17979074/error-trying-to-read-a-pdf-using-readpdf-from-the-tm-package/17981259#17981259 – Ben

回答

3

做了一些調試,並看到它失敗在tm:::pdfinfo()

status <- system2("pdfinfo", shQuote(normalizePath(file)), 
     stdout = outfile) 

此命令不會創建outfile中。根據Redirect system2 stdout to a file on windows這是一個錯誤!

相關問題