gpt4 book ai didi

jquery - 如何使用 JQuery pdfHtml5 将整个 DataTable 在 pdf 中居中

转载 作者:行者123 更新时间:2023-12-01 02:27:19 27 4
gpt4 key购买 nike

我喜欢使用 $('#tableId').DataTable() 和“pdfHtml5”按钮生成 PDF。我只是不知道如何将生成的 PDF 中的信息居中。

只有两列的表格显示在 .pdf 的左侧,但如果它只是居中的话看起来会好得多。

我很确定它应该在按钮中完成,但还没有完全弄清楚最后一点。

当前示例(不太有效):

extend:"pdfHtml5",
className: "btn",
text: "Export To PDF",
title: "PDF Title",
filename: "AFileName",
messageTop: "Test Message",

// And this is where I think I'm close...
customize: function(doc) {
// doc ? = ?
}

有什么想法吗?

最佳答案

查看doccontent部分。第二个索引是表元素。例如,您可以强制左/右页边距

customize: function(doc) {
doc.content[1].margin = [ 100, 0, 100, 0 ] //left, top, right, bottom
}

这将使表格居中,根据您的需要设置值。已查看文档,似乎没有办法自动“居中”页面内容。有 alignment 选项,但这些选项用于渲染内容(例如表格)内的文本对齐。

关于jquery - 如何使用 JQuery pdfHtml5 将整个 DataTable 在 pdf 中居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48120995/

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