【发布时间】:2021-12-24 05:17:19
【问题描述】:
我正在使用datadrivencv R 包来生成简历。在 html 中呈现默认简历可以正常工作,但是当我使用提供的代码(见下文)打印到 pdf 时,侧边栏从纯色变为渐变。如果您将 dd_cv.css 文件中的 --sidebar-background-color: 调整为更暗的东西,例如--sidebar-background-color: #727273;,这更容易看出。有没有办法防止这种情况发生?
datadrivencv::use_datadriven_cv(
full_name = "Nick Strayer",
data_location = "https://docs.google.com/spreadsheets/d/14MQICF2F8-vf8CKPF1m4lyGKO6_thG-4aSwat1e2TWc",
pdf_location = "https://github.com/nstrayer/cv/raw/master/strayer_cv.pdf",
html_location = "nickstrayer.me/cv/",
source_location = "https://github.com/nstrayer/cv"
)
datadrivencv::use_csv_data_storage()
要渲染 cv,您必须进入 cv.rmd 文件并在第 25 行将 data_location 更改为 data_location = data/。然后运行
# This script builds both the HTML and PDF versions of your CV
# If you wanted to speed up rendering for googlesheets driven CVs you could use
# this script to cache a version of the CV_Printer class with data already
# loaded and load the cached version in the .Rmd instead of re-fetching it twice
# for the HTML and PDF rendering. This exercise is left to the reader.
# Knit the HTML version
rmarkdown::render("cv.rmd",
params = list(pdf_mode = FALSE),
output_file = "cv.html")
# Knit the PDF version to temporary html location
tmp_html_cv_loc <- fs::file_temp(ext = ".html")
rmarkdown::render("cv.rmd",
params = list(pdf_mode = TRUE),
output_file = tmp_html_cv_loc)
# Convert to PDF using Pagedown
pagedown::chrome_print(input = tmp_html_cv_loc,
output = "cv.pdf")
【问题讨论】:
-
您检查过
tmp_html_cv_lochtml 文件吗?它有渐变色还是纯色?如果您无法获取临时文件,请使用output_file = "cv_pdf.hml"而不是utput_file = tmp_html_cv_loc
标签: css r pdf r-markdown pagedown