1
0
mirror of https://github.com/vbalien/voca.git synced 2025-12-06 11:26:21 +09:00
This commit is contained in:
2022-03-03 18:45:53 +09:00
parent e938c82fbe
commit f95e461427
2 changed files with 16 additions and 8 deletions

File diff suppressed because one or more lines are too long

View File

@@ -129,13 +129,13 @@ export async function makePdf(
if (type === "TEST") {
for (let i = 0; i < voca_list.length; ++i) {
const data = voca_list[i];
const pageLastItem =
voca_list.at((perPage * (Math.floor(i / perPage) + 1)) - 1) ??
voca_list.at(-1);
if (i % perPage === 0) {
if (page) {
page.node.set(PDFName.of("Annots"), pdfDoc.context.obj(pdfUrlList));
}
pdfUrlList = [];
page = pdfDoc.addPage();
yCursor = 1;
col = -1;
}
@@ -155,16 +155,20 @@ export async function makePdf(
blind: true,
});
yCursor++;
if (page && data === pageLastItem) {
page.node.set(PDFName.of("Annots"), pdfDoc.context.obj(pdfUrlList));
}
}
}
// 답 생성
for (let i = 0; i < voca_list.length; ++i) {
const data = voca_list[i];
const pageLastItem =
voca_list.at((perPage * (Math.floor(i / perPage) + 1)) - 1) ??
voca_list.at(-1);
if (i % perPage === 0) {
if (page) {
page.node.set(PDFName.of("Annots"), pdfDoc.context.obj(pdfUrlList));
}
pdfUrlList = [];
page = pdfDoc.addPage();
yCursor = 1;
@@ -186,6 +190,10 @@ export async function makePdf(
blind: false,
});
yCursor++;
if (page && data === pageLastItem) {
page.node.set(PDFName.of("Annots"), pdfDoc.context.obj(pdfUrlList));
}
}
const pdfBytes = await pdfDoc.save();