我有在將值保存到資料庫后生成 pdf 檔案的 API。我的客戶需要生成此 pdf,然后通過郵件發送。他給我發了那個pdf應該是什么樣子的照片。我重新創建了它,它看起來和那張照片一樣,但很難閱讀,因為缺少垂直線。我查看了檔案,也嘗試了谷歌,但我沒有找到任何東西。這是我的 PDF 的樣子:

如您所見,缺少垂直線,因此更難閱讀。
有沒有可能添加垂直線?
這是我的代碼:
let doc = new PDFDocument({ margin: 30, size: "A4" });
doc.pipe(
fs.createWriteStream(`${problemName}_${creationDate}` ".pdf")
);
const table = {
title:
"Zápis koordinátora "
koordinatorName
" zo dna "
creationDate
".",
divider: {
header: { disabled: true },
horizontal: { disabled: false, width: 1, opacity: 1 },
padding: 5,
columnSpacing: 10,
},
headers: [
{ width: 130, renderer: null },
{ width: 130, renderer: null },
{ width: 130, renderer: null },
{ width: 130, renderer: null },
],
rows: [
["Nazov", problemName, "", ""],
[
"Nazov staveniska (Projekt)",
constructionName,
"Na vedomie komu",
"mailing list 1",
],
[
"Vytvoril koordinator BOZP",
koordinatorName,
"Priorita",
problemPriority,
],
["Datum zistenia", creationDate, "Datum odstranenia", ""],
[
"Zodpovedny za vyriesenie zistenia",
"Janko Maly",
"Celkovy pocet zisteni v dni",
10,
],
["Miesto zistenia", discoveryPlace, "Zistenie císlo", 1],
["Popis", problemText],
[
"Navrh na udelenie sankcie",
"50€",
"Pre spolocnost",
adressedFor,
],
],
};
doc.table(table, {
prepareHeader: () => doc.font("Helvetica-Bold").fontSize(8),
prepareRow: (row, indexColumn, indexRow, rectRow, rectCell) => {
doc.font("Helvetica").fontSize(8);
indexColumn === 0;
},
});
doc.end();
我正在使用 pdfkit-table 包。
謝謝你們
uj5u.com熱心網友回復:
根據定義,簡單的 PDF 結構不是表格的,有一個單元格(頁面),并且一列可以細分為兩行或多行,文本子列之間有空空格。
這就是為什么表格很難減去[ex]
因此,在一個區域中添加彩色行很容易制作成表格,因此制作垂直子分隔線更加困難,但是該功能是在 2022 年 1 月添加的
示例見https://github.com/natancabral/pdfkit-table/issues/16#issuecomment-1012389097
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/444655.html
