You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

webshot+phantomjs无法嵌入flextable到MD/GitHub文档?求解决方案

问题:webshot + phantomjs无法截取flextable对象截图(原方法对DT表格仍有效)

问题背景

此前使用webshot包搭配phantomjs,可自动截取HTML表格截图并嵌入GitHub README等渲染文档。该方法参考《RMarkdown Cookbook》中HTML小部件转静态截图的方案,目前对DT表格仍能正常工作,但数月前开始对flextable对象失效,flextable官方暂未明确失效原因。

可复现代码

# 加载依赖包
library(flextable)
library(webshot)
library(htmltools)

# 创建示例flextable
sample_ft <- flextable(head(mtcars))
# 转换为HTML对象
ft_html_obj <- html_print(sample_ft, background = "white")

# 尝试生成截图
webshot(ft_html_obj, "flextable_screenshot.png")

报错信息

Error in webshot(ft_html_obj, "flextable_screenshot.png") : 
  PhantomJS failed to load the page. Status code: 500

需求

请求社区帮忙复现该问题,并提供可行的解决方案或替代方案。

内容的提问来源于stack exchange,提问作者rempsyc

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.18 07:52:17