tm readPDF:文件错误(con,“r"):无法打开连接 [英] tm readPDF: Error in file(con, "r") : cannot open the connection

查看:60
本文介绍了tm readPDF:文件错误(con,“r"):无法打开连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试了 tm::readPDF 文档中推荐的 示例代码:

I have tried the example code recommended in the tm::readPDF documentation:

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 返回的函数后发生):

But I get the following error (which occurs after calling the function returned by 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 条件处理).

Note that I have installed all xpdf binaries to current directory (but this is handled by the if condition).

发现这是一个错误.最简单的解决方法是什么?

推荐答案

做了一些调试,在 tm:::pdfinfo() 中看到它失败了:

Did some debugging and see it fails in tm:::pdfinfo():

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

此命令不会创建输出文件.根据 将 system2 标准输出重定向到 Windows 上的文件,这是一个错误!

This command doesn't create the outfile. According to Redirect system2 stdout to a file on windows this is a bug!

这篇关于tm readPDF:文件错误(con,“r"):无法打开连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆