简体   繁体   English

用于compactPDF的qpdf.exe?

[英]qpdf.exe for compactPDF?

I am trying to check a package that I have built (with vignette) using R CMD check --as-cran [my package] in my windows command prompt.我正在尝试在 Windows 命令提示符下使用R CMD check --as-cran [my package]我构建的包(使用小插图)。 All goes well until I get the message,一切顺利,直到我收到消息,

WARNING 'qpdf' is needed for checks on size reduction of PDFs

I have downloaded qpdf, put the unzipped folder in my program files directory, and added the bin folder to the PATH.我已经下载了 qpdf,将解压后的文件夹放在我的程序文件目录中,并将 bin 文件夹添加到 PATH。

Not quite sure what else I need to do?不太确定我还需要做什么? I have the feeling I have not installed qpdf correctly or I need to build this program itself?我感觉我没有正确安装 qpdf 或者我需要自己构建这个程序? I have read through the readme files and manual for qpdf which appear to be more aimed at unix users (which I have no experience with... I am your standard/regular windows user with little to no programming experience outside of statistical languages).我已经通读了 qpdf 的自述文件和手册,它们似乎更针对 unix 用户(我没有经验......我是你的标准/普通 Windows 用户,除了统计语言之外几乎没有编程经验)。 I have had a go at trying to build qpdf using cgywin, but ended up failing to install zlib and prec.我曾尝试使用 cgywin 构建 qpdf,但最终未能安装 zlib 和 prec。 Any tips?有小费吗?

I would try我会尝试

Sys.which(Sys.getenv("R_QPDF", "qpdf"))
Sys.getenv("PATH")

to establish that R is really not finding the qpdf executable, and see where it is looking.确定 R 确实没有找到qpdf可执行文件,并查看它在哪里。 You probably shouldn't need to rebuild everything, just figure out why R is not finding the qpdf executable ... does running qpdf from a terminal window work ... ?您可能不需要重建所有内容,只需弄清楚为什么 R 没有找到qpdf可执行文件......从终端窗口运行qpdf有效......? How are you starting R, and did it have a chance to get the new PATH definition (ie do you need to open a new terminal window, or ?? reboot ??)你是如何启动 R 的,它是否有机会获得新的 PATH 定义(即你需要打开一个新的终端窗口,还是??重启??)

The incantation above was extracted from tools::compactPDF , from the default value of the qpdf argument, on a Linux machine.上面的咒语是从tools::compactPDF提取的,从qpdf参数的默认值中qpdf ,在 Linux 机器上。 You should check for yourself, in case (eg) the Windows version is looking for qpdf.exe rather than qpdf ...您应该自己检查一下,以防(例如)Windows 版本正在寻找qpdf.exe而不是qpdf ...

There are a couple of other things to consider on a Windows machine:在 Windows 机器上还有一些其他的事情需要考虑:

If you are running the 32-bit version of R, it is important that you download the 32-bit version of qpdf, which is the version linked from the SourceForge homepage.如果您运行的是 32 位版本的 R,请务必下载32 位版本的 qpdf,这是从 SourceForge 主页链接的版本。 If you are running a 64-bit installation of R, you will need to do a bit of digging to locate the 64-bit version of qpdf, which is buried a little more deeply (version 7.0 is listed here ).如果您正在运行 R 的 64 位安装,则需要进行一些挖掘才能找到埋藏更深的 64 位版本的 qpdf(此处列出7.0 版)。

Once you have extracted the zipped qpdf directory to your hard disk, perhaps under C:\\Program Files\\ , added C:\\Program Files\\qpdf-version_number\\bin to your system PATH under the environment variables, and re-launched R, Windows needs to establish that pqdf is safe to run.将压缩的 qpdf 目录解压缩到硬盘后,可能在C:\\Program Files\\ ,将C:\\Program Files\\qpdf-version_number\\bin到环境变量下的系统PATH ,然后重新启动 R、Windows需要确定 pqdf 可以安全运行。

Navigate to C:\\Program Files\\qpdf-version_numer\\bin and execute qpdf.exe (by double-clicking).导航到C:\\Program Files\\qpdf-version_numer\\bin并执行qpdf.exe (双击)。 Windows 10 throws up a security warning, as it's an unrecognized executable file. Windows 10 发出安全警告,因为它是一个无法识别的可执行文件。 You'll need to use the more options link to find the button to run the program.您需要使用更多选项链接来找到运行程序的按钮。 This done, Windows will recognize the file as safe to run and allow other software, including R, to use it.完成后,Windows 会将该文件识别为可以安全运行并允许其他软件(包括 R)使用它。

Recent developments: If you install Rtools 3.5 qpdf is included and that warning is gone.最新动态:如果您安装Rtools 3.5,则包含 qpdf 并且该警告消失。 Rtools is a toolset for building packages on Windows and is recently reworked by Jeroen Ooms. Rtools是用于在 Windows 上构建软件包的工具集,最近由 Jeroen Ooms 重新设计。

More information : https://cran.r-project.org/bin/windows/Rtools/更多信息: https : //cran.r-project.org/bin/windows/Rtools/

Note that the changelog is incomplete, as Rtools 3.5 isn't frozen yet at the time of writing (2019-03-01).请注意,变更日志不完整,因为在撰写本文时 (2019-03-01),Rtools 3.5 尚未冻结。 Even though it's not visible on the page yet, qpdf.exe is included in the bin directory after installation.即使在页面上还看qpdf.exe它, qpdf.exe在安装后包含在bin目录中。

After installing the latest version of RTools, the warning still popped up.安装最新版本的RTools后,还是弹出警告。 However, I noticed that the Windows "where" command gave two paths to qpdf (different versions).但是,我注意到 Windows 的“where”命令为 qpdf(不同版本)提供了两条路径。 After removing the R_QPDF environment variable and removing the new install of qpdf from the Windows path, so that only qpdf in RTools was found, the warning disappeared.去掉R_QPDF环境变量,把新安装的qpdf从windows路径去掉,这样RTools里只找到qpdf,警告就消失了。

I got the same warning on Ubuntu so here's a Ubuntu solution for completeness:我在 Ubuntu 上收到了同样的警告,所以这里是一个完整的 Ubuntu 解决方案:

First update packages第一次更新包

sudo apt update

Then install qpdf with然后安装qpdf

sudo apt install qpdf

Tested on Ubuntu 20.04.在 Ubuntu 20.04 上测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM