仅在 table autoTable-jsPDF 内部显示边框
Display border only inside of table autoTable-jsPDF
我正在尝试创建一个如下所示的 table:
我已经取得了类似的成就,但我需要删除 table 之外的边框。现在我使用 lineWidth: 0.2, lineColor: [73, 138, 159]
来创建边框,但这不是我需要的。我已经检查了 autoTable-jsPDF 的所有文档,但找不到任何类似的东西。
有人可以帮我吗?谢谢。
function doPDF() {
var doc = new jsPDF("p", "mm", "a4", true);
var totalPaginas = "{total_pages_count_string}";
var pagActual = 0;
doc.autoTable({
startY: 40,
head: [
[
{
content: "",
colSpan: 5,
styles: { halign: "center", fillColor: [43, 130, 158] }
}
]
],
body: [
[
{
content: "TÍTULO",
colSpan: 1,
styles: {
valign: "middle",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
},
{ content: "TÍTULO", colSpan: 4, styles: { valign: "middle" } }
],
[
{
content: "ESTRATÉGIA DIDÁCTICA",
colSpan: 1,
styles: {
valign: "middle",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
},
{
content: "ESTRATÉGIA DIDÁCTICA",
colSpan: 4,
styles: { valign: "middle" }
}
],
[
{
content: "OBJETIVOS",
colSpan: 1,
styles: {
valign: "middle",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
},
{ content: "OBJETIVOS", colSpan: 4, styles: { valign: "middle" } }
],
[
{
content: "ESPACIO",
styles: {
valign: "middle",
halign: "center",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
},
{
content: "TIEMPO",
styles: {
valign: "middle",
halign: "center",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
},
{
content: "DINÁMICA",
styles: {
valign: "middle",
halign: "center",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
},
{
content: "SITUACIÓN DE JUEGO",
styles: {
valign: "middle",
halign: "center",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
},
{
content: "COORDINACIÓN",
styles: {
valign: "middle",
halign: "center",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
}
],
[
{ content: "text", styles: { valign: "middle", halign: "center" } },
{ content: "text", styles: { valign: "middle", halign: "center" } },
{ content: "text", styles: { valign: "middle", halign: "center" } },
{ content: "text", styles: { valign: "middle", halign: "center" } },
{ content: "text", styles: { valign: "middle", halign: "center" } }
],
[{ content: "", colSpan: 5 }]
],
columnStyles: {
0: { cellWidth: 40 }
},
bodyStyles: {
lineWidth: 0.2,
lineColor: [73, 138, 159]
},
theme: "plain"
});
var primera_tabla = doc.lastAutoTable.finalY;
doc.autoTable({
head: [
[
{
content: "ACCIÓN TÉCNICA / COORDINATIVA",
styles: { halign: "center", fillColor: [244, 247, 249] }
},
{
content: "INTENCIÓN TÁCTICA / PRINCIPIO COLECTIVO",
styles: { halign: "center", fillColor: [244, 247, 249] }
}
]
],
styles: {
lineColor: [73, 138, 159],
lineWidth: 0.2
},
theme: "plain",
startY: primera_tabla
});
if (typeof doc.putTotalPages === "function") {
doc.putTotalPages(totalPaginas);
}
doc.save("pdf.pdf");
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.4.3/jspdf.plugin.autotable.min.js"></script>
<button onclick="doPDF()">Do</button>
您可以使用以下技巧在 table 周围画一个白色边框:
doc.autoTable({
// ...
tableLineColor: [255, 255, 255],
tableLineWidth: 1,
})
function doPDF() {
var doc = new jsPDF("p", "mm", "a4", true);
var totalPaginas = "{total_pages_count_string}";
var pagActual = 0;
doc.autoTable({
startY: 40,
head: [
[
{
content: "",
colSpan: 5,
styles: { halign: "center", fillColor: [43, 130, 158] }
}
]
],
body: [
[
{
content: "TÍTULO",
colSpan: 1,
styles: {
valign: "middle",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
},
{ content: "TÍTULO", colSpan: 4, styles: { valign: "middle" } }
],
[
{
content: "ESTRATÉGIA DIDÁCTICA",
colSpan: 1,
styles: {
valign: "middle",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
},
{
content: "ESTRATÉGIA DIDÁCTICA",
colSpan: 4,
styles: { valign: "middle" }
}
],
[
{
content: "OBJETIVOS",
colSpan: 1,
styles: {
valign: "middle",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
},
{ content: "OBJETIVOS", colSpan: 4, styles: { valign: "middle" } }
],
[
{
content: "ESPACIO",
styles: {
valign: "middle",
halign: "center",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
},
{
content: "TIEMPO",
styles: {
valign: "middle",
halign: "center",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
},
{
content: "DINÁMICA",
styles: {
valign: "middle",
halign: "center",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
},
{
content: "SITUACIÓN DE JUEGO",
styles: {
valign: "middle",
halign: "center",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
},
{
content: "COORDINACIÓN",
styles: {
valign: "middle",
halign: "center",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
}
],
[
{ content: "text", styles: { valign: "middle", halign: "center" } },
{ content: "text", styles: { valign: "middle", halign: "center" } },
{ content: "text", styles: { valign: "middle", halign: "center" } },
{ content: "text", styles: { valign: "middle", halign: "center" } },
{ content: "text", styles: { valign: "middle", halign: "center" } }
],
[{ content: "", colSpan: 5 }]
],
columnStyles: {
0: { cellWidth: 40 }
},
bodyStyles: {
lineWidth: 0.2,
lineColor: [73, 138, 159]
},
theme: "plain",
tableLineColor: [255, 255, 255],
tableLineWidth: 1,
});
var primera_tabla = doc.lastAutoTable.finalY;
doc.autoTable({
head: [
[
{
content: "ACCIÓN TÉCNICA / COORDINATIVA",
styles: { halign: "center", fillColor: [244, 247, 249] }
},
{
content: "INTENCIÓN TÁCTICA / PRINCIPIO COLECTIVO",
styles: { halign: "center", fillColor: [244, 247, 249] }
}
]
],
styles: {
lineColor: [73, 138, 159],
lineWidth: 0.2
},
theme: "plain",
startY: primera_tabla
});
if (typeof doc.putTotalPages === "function") {
doc.putTotalPages(totalPaginas);
}
doc.save("pdf.pdf");
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.4.3/jspdf.plugin.autotable.min.js"></script>
<button onclick="doPDF()">Do</button>
我正在尝试创建一个如下所示的 table:
我已经取得了类似的成就,但我需要删除 table 之外的边框。现在我使用 lineWidth: 0.2, lineColor: [73, 138, 159]
来创建边框,但这不是我需要的。我已经检查了 autoTable-jsPDF 的所有文档,但找不到任何类似的东西。
有人可以帮我吗?谢谢。
function doPDF() {
var doc = new jsPDF("p", "mm", "a4", true);
var totalPaginas = "{total_pages_count_string}";
var pagActual = 0;
doc.autoTable({
startY: 40,
head: [
[
{
content: "",
colSpan: 5,
styles: { halign: "center", fillColor: [43, 130, 158] }
}
]
],
body: [
[
{
content: "TÍTULO",
colSpan: 1,
styles: {
valign: "middle",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
},
{ content: "TÍTULO", colSpan: 4, styles: { valign: "middle" } }
],
[
{
content: "ESTRATÉGIA DIDÁCTICA",
colSpan: 1,
styles: {
valign: "middle",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
},
{
content: "ESTRATÉGIA DIDÁCTICA",
colSpan: 4,
styles: { valign: "middle" }
}
],
[
{
content: "OBJETIVOS",
colSpan: 1,
styles: {
valign: "middle",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
},
{ content: "OBJETIVOS", colSpan: 4, styles: { valign: "middle" } }
],
[
{
content: "ESPACIO",
styles: {
valign: "middle",
halign: "center",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
},
{
content: "TIEMPO",
styles: {
valign: "middle",
halign: "center",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
},
{
content: "DINÁMICA",
styles: {
valign: "middle",
halign: "center",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
},
{
content: "SITUACIÓN DE JUEGO",
styles: {
valign: "middle",
halign: "center",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
},
{
content: "COORDINACIÓN",
styles: {
valign: "middle",
halign: "center",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
}
],
[
{ content: "text", styles: { valign: "middle", halign: "center" } },
{ content: "text", styles: { valign: "middle", halign: "center" } },
{ content: "text", styles: { valign: "middle", halign: "center" } },
{ content: "text", styles: { valign: "middle", halign: "center" } },
{ content: "text", styles: { valign: "middle", halign: "center" } }
],
[{ content: "", colSpan: 5 }]
],
columnStyles: {
0: { cellWidth: 40 }
},
bodyStyles: {
lineWidth: 0.2,
lineColor: [73, 138, 159]
},
theme: "plain"
});
var primera_tabla = doc.lastAutoTable.finalY;
doc.autoTable({
head: [
[
{
content: "ACCIÓN TÉCNICA / COORDINATIVA",
styles: { halign: "center", fillColor: [244, 247, 249] }
},
{
content: "INTENCIÓN TÁCTICA / PRINCIPIO COLECTIVO",
styles: { halign: "center", fillColor: [244, 247, 249] }
}
]
],
styles: {
lineColor: [73, 138, 159],
lineWidth: 0.2
},
theme: "plain",
startY: primera_tabla
});
if (typeof doc.putTotalPages === "function") {
doc.putTotalPages(totalPaginas);
}
doc.save("pdf.pdf");
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.4.3/jspdf.plugin.autotable.min.js"></script>
<button onclick="doPDF()">Do</button>
您可以使用以下技巧在 table 周围画一个白色边框:
doc.autoTable({
// ...
tableLineColor: [255, 255, 255],
tableLineWidth: 1,
})
function doPDF() {
var doc = new jsPDF("p", "mm", "a4", true);
var totalPaginas = "{total_pages_count_string}";
var pagActual = 0;
doc.autoTable({
startY: 40,
head: [
[
{
content: "",
colSpan: 5,
styles: { halign: "center", fillColor: [43, 130, 158] }
}
]
],
body: [
[
{
content: "TÍTULO",
colSpan: 1,
styles: {
valign: "middle",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
},
{ content: "TÍTULO", colSpan: 4, styles: { valign: "middle" } }
],
[
{
content: "ESTRATÉGIA DIDÁCTICA",
colSpan: 1,
styles: {
valign: "middle",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
},
{
content: "ESTRATÉGIA DIDÁCTICA",
colSpan: 4,
styles: { valign: "middle" }
}
],
[
{
content: "OBJETIVOS",
colSpan: 1,
styles: {
valign: "middle",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
},
{ content: "OBJETIVOS", colSpan: 4, styles: { valign: "middle" } }
],
[
{
content: "ESPACIO",
styles: {
valign: "middle",
halign: "center",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
},
{
content: "TIEMPO",
styles: {
valign: "middle",
halign: "center",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
},
{
content: "DINÁMICA",
styles: {
valign: "middle",
halign: "center",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
},
{
content: "SITUACIÓN DE JUEGO",
styles: {
valign: "middle",
halign: "center",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
},
{
content: "COORDINACIÓN",
styles: {
valign: "middle",
halign: "center",
fillColor: [244, 247, 249],
fontStyle: "bold"
}
}
],
[
{ content: "text", styles: { valign: "middle", halign: "center" } },
{ content: "text", styles: { valign: "middle", halign: "center" } },
{ content: "text", styles: { valign: "middle", halign: "center" } },
{ content: "text", styles: { valign: "middle", halign: "center" } },
{ content: "text", styles: { valign: "middle", halign: "center" } }
],
[{ content: "", colSpan: 5 }]
],
columnStyles: {
0: { cellWidth: 40 }
},
bodyStyles: {
lineWidth: 0.2,
lineColor: [73, 138, 159]
},
theme: "plain",
tableLineColor: [255, 255, 255],
tableLineWidth: 1,
});
var primera_tabla = doc.lastAutoTable.finalY;
doc.autoTable({
head: [
[
{
content: "ACCIÓN TÉCNICA / COORDINATIVA",
styles: { halign: "center", fillColor: [244, 247, 249] }
},
{
content: "INTENCIÓN TÁCTICA / PRINCIPIO COLECTIVO",
styles: { halign: "center", fillColor: [244, 247, 249] }
}
]
],
styles: {
lineColor: [73, 138, 159],
lineWidth: 0.2
},
theme: "plain",
startY: primera_tabla
});
if (typeof doc.putTotalPages === "function") {
doc.putTotalPages(totalPaginas);
}
doc.save("pdf.pdf");
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.4.3/jspdf.plugin.autotable.min.js"></script>
<button onclick="doPDF()">Do</button>