gpt4 book ai didi

replace - 如何在 wkhtmltopdf 中使用 "--replace"

转载 作者:行者123 更新时间:2023-12-04 15:57:29 26 4
gpt4 key购买 nike

我看到了所有内容,没有看到使用“--replace”的方式的内容。
如何在 wkhtmltopdf 中使用“--replace”。
请给我一个例子,谢谢。:)

最佳答案

假设您有一个页脚 my_footer.html,其中包含以下内容:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script>
function substitutePdfVariables() {

function getParameterByName(name) {
var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
}

function substitute(name) {
var value = getParameterByName(name);
var elements = document.getElementsByClassName(name);

for (var i = 0; elements && i < elements.length; i++) {
elements[i].textContent = value;
}
}

['username'/*, 'topage', 'page',.. etc and any variable you would want to replace */]
.forEach(function(param) {
substitute(param);
});
}
</script>
</head>
<body onload="substitutePdfVariables()">
<span class="username"></span>
</body>
</html>

您可以用一些值替换“用户名”:
wkhtmltopdf my_super_html.html --footer-html my_footer.html --replace "username" "Veaer"

请注意,我使用 javascript 将命名变量替换为我的值。

关于replace - 如何在 wkhtmltopdf 中使用 "--replace",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26985285/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com