r - R kableExtra save_kable 失败,magick_image_readpath 出错
问题描述
我正在尝试将一个非常简单的表格保存kableExtra
为 pdf:
kable("a^2 + $a^2$") %>%
save_kable("~/test.pdf")
第一次执行此操作时,我得到一个基本上为空的 pdf 文件(一张白纸)和此错误消息(英文:“数据不足”):
如果我想重复该命令,我会收到以下错误消息:
Note that HTML color may not be displayed on PDF properly.
Error in magick_image_readpath(path, density, depth, strip, defines) :
rsession.exe: PDFDelegateFailed `[ghostscript library 9.54] -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r300x300" "-sOutputFile=C:/Users/morit/AppData/Local/Temp/RtmpkloYkX/magick-QaJaNe3mklg4TaBJsMRxFHkKmjJsXsFU%d" "-fC:/Users/morit/AppData/Local/Temp/RtmpkloYkX/magick-tQOJN0ahz4VFW2gIMKxiT_yLT5A4PAs7" "-fC:/Users/morit/AppData/Local/Temp/RtmpkloYkX/magick-I2fwhRyRj0BaZbXvlYZjhZ_mnewfOcK1": (null)' @ error/pdf.c/ReadPDFImage/666
debug(save_kable)
我使用这一行跟踪问题:
magick::image_write(img_rework, file, density = density)
在第一次使用时,现有的 PDF(它是之前创建的 result <- webshot::webshot(file_temp_html, file, ...)
,在调试时甚至可以打开)被重写 - 并被破坏!
然后第二次执行会在这里抛出大量错误:img_rework <- magick::image_read(file, density = density)
我刚刚从这里重新安装了 ImageMagick并更新了 GhostScript(均为 64 位)。我还更新了kableExtra
和magick
包。
有任何想法吗?
这是我的会话信息:
R version 4.0.5 (2021-03-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)
Matrix products: default
locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252 LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] kableExtra_1.3.4 usethis_1.6.3
loaded via a namespace (and not attached):
[1] Rcpp_1.0.5 rstudioapi_0.11 knitr_1.30 xml2_1.3.2 magrittr_2.0.1 rvest_0.3.6
[7] munsell_0.5.0 colorspace_1.4-1 viridisLite_0.3.0 R6_2.5.0 rlang_0.4.10 highr_0.8
[13] stringr_1.4.0 httr_1.4.2 tools_4.0.5 webshot_0.5.2 xfun_0.20 htmltools_0.5.0.9003
[19] systemfonts_1.0.0 yaml_2.2.1 digest_0.6.27 lifecycle_0.2.0 processx_3.4.4 callr_3.5.1
[25] ps_1.4.0 fs_1.5.0 glue_1.4.2 evaluate_0.14 rmarkdown_2.6 stringi_1.5.3
[31] compiler_4.0.5 magick_2.7.2 scales_1.1.1 jsonlite_1.7.2 svglite_2.0.0
解决方案
推荐阅读
- batch-file - Set command gives error when trying parameter expansion to replace characters
- flutter - 指导我在屏幕关闭时运行 SetState()
- java - 如何将匹配器添加到 HttpSecurity spring web secure
- sql - 如何访问 LotusScript 代理中的 SQL 计数结果值
- python - Python 中 Unicode 字符的显示问题(组合字符、假名字符等)
- scala - How to avoid OutOfMemoryError in a small ArrayBuffer in a scope of small function?
- azure-devops - Not Getting Azure DevOps Code Coverage Information From Azure DevOps Services REST APIs
- ios - SwiftUI SQLite ForEach list data
- javascript - 如何在 JavaScript 中生成 n 矩阵
- sql-server - 存储过程和触发器执行阻塞