persian-data-grid 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/OFL.txt +93 -0
- package/README.md +179 -22
- package/dist/ERPTableGroupRow-E5Q6FYDS.js +125 -0
- package/dist/ERPTableGroupRow-E5Q6FYDS.js.map +1 -0
- package/dist/ERPTableGroupRow-F2IPDYL5.cjs +131 -0
- package/dist/ERPTableGroupRow-F2IPDYL5.cjs.map +1 -0
- package/dist/GridPlugin-Bewn0X51.d.ts +57 -0
- package/dist/GridPlugin-DewWufGZ.d.cts +57 -0
- package/dist/GridPresenceService-GEH6535Q.js +3 -0
- package/dist/GridPresenceService-GEH6535Q.js.map +1 -0
- package/dist/GridPresenceService-RDN5FXHQ.cjs +12 -0
- package/dist/GridPresenceService-RDN5FXHQ.cjs.map +1 -0
- package/dist/GridSession-CeIfVFck.d.ts +2625 -0
- package/dist/GridSession-CmQn2RnL.d.cts +2625 -0
- package/dist/GridSyncService-3JQLEY65.cjs +12 -0
- package/dist/GridSyncService-3JQLEY65.cjs.map +1 -0
- package/dist/GridSyncService-GECXGEKL.js +3 -0
- package/dist/GridSyncService-GECXGEKL.js.map +1 -0
- package/dist/PdfRenderer-B9FJaCo_.d.cts +22 -0
- package/dist/PdfRenderer-bN7ca_Aj.d.ts +22 -0
- package/dist/RemoteApi-CCQxiSf1.d.cts +28 -0
- package/dist/RemoteApi-CCQxiSf1.d.ts +28 -0
- package/dist/SelectImpl-NM4O4IGW.js +447 -0
- package/dist/SelectImpl-NM4O4IGW.js.map +1 -0
- package/dist/SelectImpl-W2EI4T7O.cjs +453 -0
- package/dist/SelectImpl-W2EI4T7O.cjs.map +1 -0
- package/dist/UITableController-C71LXBiX.d.ts +678 -0
- package/dist/UITableController-CIwnHIw8.d.cts +678 -0
- package/dist/VazirmatnPdfRenderer-CpCqA-Wh.d.cts +96 -0
- package/dist/VazirmatnPdfRenderer-D46smncn.d.ts +96 -0
- package/dist/adapters/arian-erp.cjs +89 -0
- package/dist/adapters/arian-erp.cjs.map +1 -0
- package/dist/adapters/arian-erp.d.cts +62 -0
- package/dist/adapters/arian-erp.d.ts +62 -0
- package/dist/adapters/arian-erp.js +79 -0
- package/dist/adapters/arian-erp.js.map +1 -0
- package/dist/appendAtEnd-RHIQRG2W.cjs +35 -0
- package/dist/appendAtEnd-RHIQRG2W.cjs.map +1 -0
- package/dist/appendAtEnd-TJEABLGD.js +33 -0
- package/dist/appendAtEnd-TJEABLGD.js.map +1 -0
- package/dist/applyImportedRows-C2fWYoPy.d.cts +135 -0
- package/dist/applyImportedRows-Cqh_N_0k.d.ts +135 -0
- package/dist/applyRowVisibilityHandler-Q64ZFC7A.cjs +86 -0
- package/dist/applyRowVisibilityHandler-Q64ZFC7A.cjs.map +1 -0
- package/dist/applyRowVisibilityHandler-ZLZXQEGY.js +84 -0
- package/dist/applyRowVisibilityHandler-ZLZXQEGY.js.map +1 -0
- package/dist/broadcastChannelTransport-FHUMV76O.cjs +12 -0
- package/dist/broadcastChannelTransport-FHUMV76O.cjs.map +1 -0
- package/dist/broadcastChannelTransport-MIH53VNZ.js +3 -0
- package/dist/broadcastChannelTransport-MIH53VNZ.js.map +1 -0
- package/dist/callbackRemoteApi-BYLjmSI6.d.ts +51 -0
- package/dist/callbackRemoteApi-Cv26MmSD.d.cts +51 -0
- package/dist/cellRenderContext-BaNh4qn_.d.ts +42 -0
- package/dist/cellRenderContext-DvngkptV.d.cts +42 -0
- package/dist/chunk-27ALJSZP.js +12187 -0
- package/dist/chunk-27ALJSZP.js.map +1 -0
- package/dist/chunk-3HP3HQCW.cjs +688 -0
- package/dist/chunk-3HP3HQCW.cjs.map +1 -0
- package/dist/chunk-3Y3KKGEC.js +3 -0
- package/dist/chunk-3Y3KKGEC.js.map +1 -0
- package/dist/chunk-52LFOPXD.cjs +588 -0
- package/dist/chunk-52LFOPXD.cjs.map +1 -0
- package/dist/chunk-5ALMNLUR.cjs +1408 -0
- package/dist/chunk-5ALMNLUR.cjs.map +1 -0
- package/dist/chunk-5HKVMPBD.js +937 -0
- package/dist/chunk-5HKVMPBD.js.map +1 -0
- package/dist/chunk-72IVAOTK.cjs +38 -0
- package/dist/chunk-72IVAOTK.cjs.map +1 -0
- package/dist/chunk-77UXAJII.js +112 -0
- package/dist/chunk-77UXAJII.js.map +1 -0
- package/dist/chunk-7GWV5HGO.js +36 -0
- package/dist/chunk-7GWV5HGO.js.map +1 -0
- package/dist/chunk-7T6AWRPU.js +581 -0
- package/dist/chunk-7T6AWRPU.js.map +1 -0
- package/dist/chunk-AU3RDJYQ.js +243 -0
- package/dist/chunk-AU3RDJYQ.js.map +1 -0
- package/dist/chunk-CILNIWYW.cjs +100 -0
- package/dist/chunk-CILNIWYW.cjs.map +1 -0
- package/dist/chunk-CMQ4VLCW.cjs +840 -0
- package/dist/chunk-CMQ4VLCW.cjs.map +1 -0
- package/dist/chunk-DFFP7SJ6.cjs +257 -0
- package/dist/chunk-DFFP7SJ6.cjs.map +1 -0
- package/dist/chunk-E2J533UH.cjs +53 -0
- package/dist/chunk-E2J533UH.cjs.map +1 -0
- package/dist/chunk-EBV6HGZB.cjs +33 -0
- package/dist/chunk-EBV6HGZB.cjs.map +1 -0
- package/dist/chunk-F4PYOYHR.js +112 -0
- package/dist/chunk-F4PYOYHR.js.map +1 -0
- package/dist/chunk-F6EMC75A.cjs +34 -0
- package/dist/chunk-F6EMC75A.cjs.map +1 -0
- package/dist/chunk-GKE33FOJ.js +32 -0
- package/dist/chunk-GKE33FOJ.js.map +1 -0
- package/dist/chunk-GQEDLUMB.js +168 -0
- package/dist/chunk-GQEDLUMB.js.map +1 -0
- package/dist/chunk-HLOHWFOA.js +645 -0
- package/dist/chunk-HLOHWFOA.js.map +1 -0
- package/dist/chunk-IMPCRWYP.cjs +251 -0
- package/dist/chunk-IMPCRWYP.cjs.map +1 -0
- package/dist/chunk-IPPIXOVQ.js +317 -0
- package/dist/chunk-IPPIXOVQ.js.map +1 -0
- package/dist/chunk-J4XJ4UBC.js +1404 -0
- package/dist/chunk-J4XJ4UBC.js.map +1 -0
- package/dist/chunk-J7CPPFXT.cjs +89 -0
- package/dist/chunk-J7CPPFXT.cjs.map +1 -0
- package/dist/chunk-JOICD47Q.cjs +41 -0
- package/dist/chunk-JOICD47Q.cjs.map +1 -0
- package/dist/chunk-KCNTKYUY.js +206 -0
- package/dist/chunk-KCNTKYUY.js.map +1 -0
- package/dist/chunk-KHMG6EI2.js +13 -0
- package/dist/chunk-KHMG6EI2.js.map +1 -0
- package/dist/chunk-KMRURD5J.cjs +15 -0
- package/dist/chunk-KMRURD5J.cjs.map +1 -0
- package/dist/chunk-KRJG3KMP.cjs +174 -0
- package/dist/chunk-KRJG3KMP.cjs.map +1 -0
- package/dist/chunk-LY27YAXE.cjs +208 -0
- package/dist/chunk-LY27YAXE.cjs.map +1 -0
- package/dist/chunk-MT3KLB2Q.cjs +944 -0
- package/dist/chunk-MT3KLB2Q.cjs.map +1 -0
- package/dist/chunk-MUQQKPWR.js +84 -0
- package/dist/chunk-MUQQKPWR.js.map +1 -0
- package/dist/chunk-N7SJTINL.cjs +4 -0
- package/dist/chunk-N7SJTINL.cjs.map +1 -0
- package/dist/chunk-NB5GCGHL.js +833 -0
- package/dist/chunk-NB5GCGHL.js.map +1 -0
- package/dist/chunk-NQUVAJQA.js +298 -0
- package/dist/chunk-NQUVAJQA.js.map +1 -0
- package/dist/chunk-NTV2UUAJ.cjs +149 -0
- package/dist/chunk-NTV2UUAJ.cjs.map +1 -0
- package/dist/chunk-PJQWHF6T.js +31 -0
- package/dist/chunk-PJQWHF6T.js.map +1 -0
- package/dist/chunk-PQY54EL5.js +248 -0
- package/dist/chunk-PQY54EL5.js.map +1 -0
- package/dist/chunk-Q7TBBUTX.cjs +110 -0
- package/dist/chunk-Q7TBBUTX.cjs.map +1 -0
- package/dist/chunk-QZN7R2WP.cjs +114 -0
- package/dist/chunk-QZN7R2WP.cjs.map +1 -0
- package/dist/chunk-RKVSJU46.js +35 -0
- package/dist/chunk-RKVSJU46.js.map +1 -0
- package/dist/chunk-SVO62ZV2.js +50 -0
- package/dist/chunk-SVO62ZV2.js.map +1 -0
- package/dist/chunk-SX4VQXAA.cjs +114 -0
- package/dist/chunk-SX4VQXAA.cjs.map +1 -0
- package/dist/chunk-SZ7BLAY3.js +92 -0
- package/dist/chunk-SZ7BLAY3.js.map +1 -0
- package/dist/chunk-TN4MG6FY.js +112 -0
- package/dist/chunk-TN4MG6FY.js.map +1 -0
- package/dist/chunk-UC7PHDM6.cjs +331 -0
- package/dist/chunk-UC7PHDM6.cjs.map +1 -0
- package/dist/chunk-UXVLYUUW.js +108 -0
- package/dist/chunk-UXVLYUUW.js.map +1 -0
- package/dist/chunk-VBAZ77Q4.js +932 -0
- package/dist/chunk-VBAZ77Q4.js.map +1 -0
- package/dist/chunk-VSAFQTW5.cjs +319 -0
- package/dist/chunk-VSAFQTW5.cjs.map +1 -0
- package/dist/chunk-VYJQ2HTA.cjs +936 -0
- package/dist/chunk-VYJQ2HTA.cjs.map +1 -0
- package/dist/chunk-W5256BJ4.js +56 -0
- package/dist/chunk-W5256BJ4.js.map +1 -0
- package/dist/chunk-WTHTVKVI.cjs +12299 -0
- package/dist/chunk-WTHTVKVI.cjs.map +1 -0
- package/dist/chunk-WUMOSOEK.cjs +62 -0
- package/dist/chunk-WUMOSOEK.cjs.map +1 -0
- package/dist/chunk-XLRE2J25.js +140 -0
- package/dist/chunk-XLRE2J25.js.map +1 -0
- package/dist/chunk-Z4QPZ3Z3.cjs +114 -0
- package/dist/chunk-Z4QPZ3Z3.cjs.map +1 -0
- package/dist/createEngineGridQuery-BBkud5oE.d.ts +939 -0
- package/dist/createEngineGridQuery-D-fgO_jg.d.cts +939 -0
- package/dist/date-picker-jalali.cjs +263 -0
- package/dist/date-picker-jalali.cjs.map +1 -0
- package/dist/date-picker-jalali.d.cts +62 -0
- package/dist/date-picker-jalali.d.ts +62 -0
- package/dist/date-picker-jalali.js +256 -0
- package/dist/date-picker-jalali.js.map +1 -0
- package/dist/finance.cjs +205 -0
- package/dist/finance.cjs.map +1 -0
- package/dist/finance.d.cts +90 -0
- package/dist/finance.d.ts +90 -0
- package/dist/finance.js +157 -0
- package/dist/finance.js.map +1 -0
- package/dist/foldedColumn-IHDT4ARZ.cjs +66 -0
- package/dist/foldedColumn-IHDT4ARZ.cjs.map +1 -0
- package/dist/foldedColumn-TFURUKFG.js +64 -0
- package/dist/foldedColumn-TFURUKFG.js.map +1 -0
- package/dist/headless.cjs +729 -0
- package/dist/headless.cjs.map +1 -0
- package/dist/headless.d.cts +508 -0
- package/dist/headless.d.ts +508 -0
- package/dist/headless.js +226 -0
- package/dist/headless.js.map +1 -0
- package/dist/index-DN8M8Jkq.d.cts +14 -0
- package/dist/index-DmzL-F_o.d.ts +14 -0
- package/dist/index.cjs +8060 -11409
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +457 -2305
- package/dist/index.d.ts +457 -2305
- package/dist/index.js +7302 -11084
- package/dist/index.js.map +1 -1
- package/dist/locales/ar.cjs +12 -0
- package/dist/locales/ar.cjs.map +1 -0
- package/dist/locales/ar.d.cts +6 -0
- package/dist/locales/ar.d.ts +6 -0
- package/dist/locales/ar.js +3 -0
- package/dist/locales/ar.js.map +1 -0
- package/dist/locales/en.cjs +12 -0
- package/dist/locales/en.cjs.map +1 -0
- package/dist/locales/en.d.cts +6 -0
- package/dist/locales/en.d.ts +6 -0
- package/dist/locales/en.js +3 -0
- package/dist/locales/en.js.map +1 -0
- package/dist/locales/fa.cjs +12 -0
- package/dist/locales/fa.cjs.map +1 -0
- package/dist/locales/fa.d.cts +6 -0
- package/dist/locales/fa.d.ts +6 -0
- package/dist/locales/fa.js +3 -0
- package/dist/locales/fa.js.map +1 -0
- package/dist/locales/index.cjs +51 -0
- package/dist/locales/index.cjs.map +1 -0
- package/dist/locales/index.d.cts +5 -0
- package/dist/locales/index.d.ts +5 -0
- package/dist/locales/index.js +6 -0
- package/dist/locales/index.js.map +1 -0
- package/dist/memoryRecords-AWDKUJ2F.cjs +50 -0
- package/dist/memoryRecords-AWDKUJ2F.cjs.map +1 -0
- package/dist/memoryRecords-OJTGXLRH.js +47 -0
- package/dist/memoryRecords-OJTGXLRH.js.map +1 -0
- package/dist/pagedFooterTotals-DXCGDO6F.cjs +27 -0
- package/dist/pagedFooterTotals-DXCGDO6F.cjs.map +1 -0
- package/dist/pagedFooterTotals-ORWKUNE7.js +25 -0
- package/dist/pagedFooterTotals-ORWKUNE7.js.map +1 -0
- package/dist/pagedKit-MFGAJFSK.cjs +134 -0
- package/dist/pagedKit-MFGAJFSK.cjs.map +1 -0
- package/dist/pagedKit-WYWY4LRV.js +127 -0
- package/dist/pagedKit-WYWY4LRV.js.map +1 -0
- package/dist/pagedSearch-HCPJW7VM.js +38 -0
- package/dist/pagedSearch-HCPJW7VM.js.map +1 -0
- package/dist/pagedSearch-U3WCG4GN.cjs +42 -0
- package/dist/pagedSearch-U3WCG4GN.cjs.map +1 -0
- package/dist/plugins/csv.cjs +124 -0
- package/dist/plugins/csv.cjs.map +1 -0
- package/dist/plugins/csv.d.cts +44 -0
- package/dist/plugins/csv.d.ts +44 -0
- package/dist/plugins/csv.js +120 -0
- package/dist/plugins/csv.js.map +1 -0
- package/dist/plugins/excel.cjs +52 -0
- package/dist/plugins/excel.cjs.map +1 -0
- package/dist/plugins/excel.d.cts +14 -0
- package/dist/plugins/excel.d.ts +14 -0
- package/dist/plugins/excel.js +7 -0
- package/dist/plugins/excel.js.map +1 -0
- package/dist/plugins/pdf/fonts/vazirmatn.cjs +50 -0
- package/dist/plugins/pdf/fonts/vazirmatn.cjs.map +1 -0
- package/dist/plugins/pdf/fonts/vazirmatn.d.cts +24 -0
- package/dist/plugins/pdf/fonts/vazirmatn.d.ts +24 -0
- package/dist/plugins/pdf/fonts/vazirmatn.js +39 -0
- package/dist/plugins/pdf/fonts/vazirmatn.js.map +1 -0
- package/dist/plugins/pdf.cjs +24 -0
- package/dist/plugins/pdf.cjs.map +1 -0
- package/dist/plugins/pdf.d.cts +21 -0
- package/dist/plugins/pdf.d.ts +21 -0
- package/dist/plugins/pdf.js +7 -0
- package/dist/plugins/pdf.js.map +1 -0
- package/dist/presence.cjs +56 -0
- package/dist/presence.cjs.map +1 -0
- package/dist/presence.d.cts +17 -0
- package/dist/presence.d.ts +17 -0
- package/dist/presence.js +54 -0
- package/dist/presence.js.map +1 -0
- package/dist/rebuildRowVisibility-66EAZ356.cjs +21 -0
- package/dist/rebuildRowVisibility-66EAZ356.cjs.map +1 -0
- package/dist/rebuildRowVisibility-6TYM5BP2.js +19 -0
- package/dist/rebuildRowVisibility-6TYM5BP2.js.map +1 -0
- package/dist/styles.css +1440 -0
- package/dist/sync.cjs +148 -0
- package/dist/sync.cjs.map +1 -0
- package/dist/sync.d.cts +17 -0
- package/dist/sync.d.ts +17 -0
- package/dist/sync.js +146 -0
- package/dist/sync.js.map +1 -0
- package/dist/types-D__47BKv.d.cts +23 -0
- package/dist/types-D__47BKv.d.ts +23 -0
- package/package.json +185 -29
|
@@ -0,0 +1,936 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkIMPCRWYP_cjs = require('./chunk-IMPCRWYP.cjs');
|
|
4
|
+
var chunkF6EMC75A_cjs = require('./chunk-F6EMC75A.cjs');
|
|
5
|
+
var fflate = require('fflate');
|
|
6
|
+
|
|
7
|
+
// packages/plugins/pdf/src/TextPdfRenderer.ts
|
|
8
|
+
var TextPdfRenderer = class {
|
|
9
|
+
async render(source, options) {
|
|
10
|
+
const lines = [options?.title ?? "Export"];
|
|
11
|
+
const columns = source.columns.slice(0, 8);
|
|
12
|
+
lines.push(columns.map((c) => c.fieldCaption ?? c.fieldName).join(" | "));
|
|
13
|
+
for (const row of source.rows.slice(0, 40)) {
|
|
14
|
+
const prefix = row.kind === "group" ? "\u25B8 " : "";
|
|
15
|
+
lines.push(
|
|
16
|
+
prefix + columns.map((col) => {
|
|
17
|
+
const cell = row.cells[col.fieldName];
|
|
18
|
+
const raw = cell?.display ?? cell?.value ?? "";
|
|
19
|
+
return chunkF6EMC75A_cjs.formatExportValue(raw, col.fieldType).slice(0, 24);
|
|
20
|
+
}).join(" | ")
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
const content = lines.map((line, i) => {
|
|
24
|
+
const safe = line.replace(/[()\\]/g, " ");
|
|
25
|
+
const y = 750 - i * 14;
|
|
26
|
+
return `BT /F1 10 Tf 40 ${y} Td (${safe}) Tj ET`;
|
|
27
|
+
}).join("\n");
|
|
28
|
+
const stream = content;
|
|
29
|
+
const objects = [
|
|
30
|
+
"1 0 obj<< /Type /Catalog /Pages 2 0 R >>endobj\n",
|
|
31
|
+
"2 0 obj<< /Type /Pages /Kids [3 0 R] /Count 1 >>endobj\n",
|
|
32
|
+
"3 0 obj<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Contents 4 0 R /Resources<< /Font<< /F1 5 0 R >> >> >>endobj\n",
|
|
33
|
+
`4 0 obj<< /Length ${stream.length} >>stream
|
|
34
|
+
${stream}
|
|
35
|
+
endstream
|
|
36
|
+
endobj
|
|
37
|
+
`,
|
|
38
|
+
"5 0 obj<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>endobj\n"
|
|
39
|
+
];
|
|
40
|
+
let body = "%PDF-1.1\n";
|
|
41
|
+
const offsets = [0];
|
|
42
|
+
for (const obj of objects) {
|
|
43
|
+
offsets.push(body.length);
|
|
44
|
+
body += obj;
|
|
45
|
+
}
|
|
46
|
+
const xrefStart = body.length;
|
|
47
|
+
body += `xref
|
|
48
|
+
0 ${objects.length + 1}
|
|
49
|
+
`;
|
|
50
|
+
body += "0000000000 65535 f \n";
|
|
51
|
+
for (let i = 1; i <= objects.length; i += 1) {
|
|
52
|
+
body += `${String(offsets[i]).padStart(10, "0")} 00000 n
|
|
53
|
+
`;
|
|
54
|
+
}
|
|
55
|
+
body += `trailer<< /Size ${objects.length + 1} /Root 1 0 R >>
|
|
56
|
+
`;
|
|
57
|
+
body += `startxref
|
|
58
|
+
${xrefStart}
|
|
59
|
+
%%EOF
|
|
60
|
+
`;
|
|
61
|
+
return new Blob([body], { type: "application/pdf" });
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// packages/plugins/pdf/src/PdfExportPlugin.ts
|
|
66
|
+
var PdfExportPlugin = class {
|
|
67
|
+
constructor(options = {}) {
|
|
68
|
+
this.options = options;
|
|
69
|
+
this.name = "pdf-export";
|
|
70
|
+
this.unsub = null;
|
|
71
|
+
this.renderer = options.renderer ?? new TextPdfRenderer();
|
|
72
|
+
}
|
|
73
|
+
register(ctx) {
|
|
74
|
+
this.unsub = ctx.bus.subscribeAll((event) => {
|
|
75
|
+
void this.onEvent(ctx, event);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
dispose() {
|
|
79
|
+
this.unsub?.();
|
|
80
|
+
this.unsub = null;
|
|
81
|
+
}
|
|
82
|
+
async onEvent(ctx, event) {
|
|
83
|
+
if (event.type !== "EXPORT_REQUESTED") return;
|
|
84
|
+
if (event.tableId !== ctx.tableId) return;
|
|
85
|
+
const payload = event.payload;
|
|
86
|
+
if (payload.format !== "pdf") return;
|
|
87
|
+
try {
|
|
88
|
+
const source = ctx.query.getExportSource(
|
|
89
|
+
payload.collectionScope ?? "active"
|
|
90
|
+
);
|
|
91
|
+
if (!source) {
|
|
92
|
+
throw new Error("NO_EXPORT_SOURCE");
|
|
93
|
+
}
|
|
94
|
+
const blob = await this.renderer.render(source, {
|
|
95
|
+
title: payload.fileName ?? "Export",
|
|
96
|
+
direction: payload.direction,
|
|
97
|
+
template: this.options.template
|
|
98
|
+
});
|
|
99
|
+
const fileName = payload.fileName ?? `export-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.pdf`;
|
|
100
|
+
const rowCount = source.rows.length;
|
|
101
|
+
if (this.options.download !== false) {
|
|
102
|
+
chunkIMPCRWYP_cjs.downloadBlob(blob, fileName);
|
|
103
|
+
}
|
|
104
|
+
this.options.onBlob?.(blob, { fileName, rowCount });
|
|
105
|
+
await ctx.bus.publish({
|
|
106
|
+
eventId: `${Date.now()}-pdf-ok`,
|
|
107
|
+
type: "PDF_EXPORT_COMPLETED",
|
|
108
|
+
tableId: ctx.tableId,
|
|
109
|
+
streamId: `table/${ctx.tableId}/view`,
|
|
110
|
+
version: 0,
|
|
111
|
+
occurredAt: Date.now(),
|
|
112
|
+
actorId: event.actorId,
|
|
113
|
+
correlationId: event.correlationId,
|
|
114
|
+
causationId: event.eventId,
|
|
115
|
+
payload: {
|
|
116
|
+
format: "pdf",
|
|
117
|
+
rowCount,
|
|
118
|
+
blobId: fileName
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
} catch (err) {
|
|
122
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
123
|
+
await ctx.bus.publish({
|
|
124
|
+
eventId: `${Date.now()}-pdf-fail`,
|
|
125
|
+
type: "PDF_EXPORT_FAILED",
|
|
126
|
+
tableId: ctx.tableId,
|
|
127
|
+
streamId: `table/${ctx.tableId}/view`,
|
|
128
|
+
version: 0,
|
|
129
|
+
occurredAt: Date.now(),
|
|
130
|
+
actorId: event.actorId,
|
|
131
|
+
correlationId: event.correlationId,
|
|
132
|
+
causationId: event.eventId,
|
|
133
|
+
payload: {
|
|
134
|
+
format: "pdf",
|
|
135
|
+
code: message === "NO_EXPORT_SOURCE" ? message : "EXPORT_FAILED",
|
|
136
|
+
message
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
var encoder = new TextEncoder();
|
|
143
|
+
function concat(chunks) {
|
|
144
|
+
let total = 0;
|
|
145
|
+
for (const c of chunks) total += c.length;
|
|
146
|
+
const out = new Uint8Array(total);
|
|
147
|
+
let o = 0;
|
|
148
|
+
for (const c of chunks) {
|
|
149
|
+
out.set(c, o);
|
|
150
|
+
o += c.length;
|
|
151
|
+
}
|
|
152
|
+
return out;
|
|
153
|
+
}
|
|
154
|
+
function pad10(n) {
|
|
155
|
+
return String(n).padStart(10, "0");
|
|
156
|
+
}
|
|
157
|
+
var PdfBuilder = class {
|
|
158
|
+
constructor() {
|
|
159
|
+
this.objects = [];
|
|
160
|
+
}
|
|
161
|
+
addAscii(body) {
|
|
162
|
+
this.objects.push(encoder.encode(body));
|
|
163
|
+
return this.objects.length;
|
|
164
|
+
}
|
|
165
|
+
replaceAscii(objNum, body) {
|
|
166
|
+
this.objects[objNum - 1] = encoder.encode(body);
|
|
167
|
+
}
|
|
168
|
+
addFlate(uncompressed, extraDict = "") {
|
|
169
|
+
const compressed = fflate.deflateSync(uncompressed, { level: 9 });
|
|
170
|
+
const dict = `<< /Filter /FlateDecode /Length ${compressed.length} ${extraDict}>>`;
|
|
171
|
+
const header = encoder.encode(`${dict}stream
|
|
172
|
+
`);
|
|
173
|
+
const tail = encoder.encode("\nendstream\n");
|
|
174
|
+
this.objects.push(concat([header, compressed, tail]));
|
|
175
|
+
return this.objects.length;
|
|
176
|
+
}
|
|
177
|
+
/** Raw stream (e.g. JPEG with `/Filter /DCTDecode`). `dict` is a full `<< … >>`. */
|
|
178
|
+
addRawStream(data, dict) {
|
|
179
|
+
const header = encoder.encode(`${dict}
|
|
180
|
+
stream
|
|
181
|
+
`);
|
|
182
|
+
const tail = encoder.encode("\nendstream\n");
|
|
183
|
+
this.objects.push(concat([header, data, tail]));
|
|
184
|
+
return this.objects.length;
|
|
185
|
+
}
|
|
186
|
+
build() {
|
|
187
|
+
const parts = [encoder.encode("%PDF-1.4\n%\x80\x80\x80\x80\n")];
|
|
188
|
+
const offsets = [0];
|
|
189
|
+
let pos = parts[0].length;
|
|
190
|
+
for (let i = 0; i < this.objects.length; i += 1) {
|
|
191
|
+
offsets.push(pos);
|
|
192
|
+
const head = encoder.encode(`${i + 1} 0 obj
|
|
193
|
+
`);
|
|
194
|
+
const tail = encoder.encode("endobj\n");
|
|
195
|
+
const body = this.objects[i];
|
|
196
|
+
parts.push(head, body, tail);
|
|
197
|
+
pos += head.length + body.length + tail.length;
|
|
198
|
+
}
|
|
199
|
+
const xrefStart = pos;
|
|
200
|
+
let xref = `xref
|
|
201
|
+
0 ${this.objects.length + 1}
|
|
202
|
+
0000000000 65535 f
|
|
203
|
+
`;
|
|
204
|
+
for (let i = 1; i <= this.objects.length; i += 1) {
|
|
205
|
+
xref += `${pad10(offsets[i] ?? 0)} 00000 n
|
|
206
|
+
`;
|
|
207
|
+
}
|
|
208
|
+
xref += `trailer<< /Size ${this.objects.length + 1} /Root 1 0 R >>
|
|
209
|
+
`;
|
|
210
|
+
xref += `startxref
|
|
211
|
+
${xrefStart}
|
|
212
|
+
%%EOF
|
|
213
|
+
`;
|
|
214
|
+
parts.push(encoder.encode(xref));
|
|
215
|
+
return concat(parts);
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
function pdfEscapeTextHex(gids) {
|
|
219
|
+
return gids.map((g) => g.toString(16).padStart(4, "0")).join("");
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// packages/plugins/pdf/src/parseTtf.ts
|
|
223
|
+
function u16(buf, offset) {
|
|
224
|
+
return buf[offset] << 8 | buf[offset + 1];
|
|
225
|
+
}
|
|
226
|
+
function u32(buf, offset) {
|
|
227
|
+
return (buf[offset] << 24 | buf[offset + 1] << 16 | buf[offset + 2] << 8 | buf[offset + 3]) >>> 0;
|
|
228
|
+
}
|
|
229
|
+
function i16(buf, offset) {
|
|
230
|
+
const v = u16(buf, offset);
|
|
231
|
+
return v > 32767 ? v - 65536 : v;
|
|
232
|
+
}
|
|
233
|
+
function tagAt(buf, offset) {
|
|
234
|
+
return String.fromCharCode(buf[offset], buf[offset + 1], buf[offset + 2], buf[offset + 3]);
|
|
235
|
+
}
|
|
236
|
+
function tableMap(buf) {
|
|
237
|
+
const numTables = u16(buf, 4);
|
|
238
|
+
const tables = /* @__PURE__ */ new Map();
|
|
239
|
+
for (let i = 0; i < numTables; i += 1) {
|
|
240
|
+
const o = 12 + i * 16;
|
|
241
|
+
tables.set(tagAt(buf, o), { offset: u32(buf, o + 8), length: u32(buf, o + 12) });
|
|
242
|
+
}
|
|
243
|
+
return tables;
|
|
244
|
+
}
|
|
245
|
+
function parseCmap(buf, cmapOffset) {
|
|
246
|
+
const numTables = u16(buf, cmapOffset + 2);
|
|
247
|
+
let format4 = -1;
|
|
248
|
+
let format12 = -1;
|
|
249
|
+
for (let i = 0; i < numTables; i += 1) {
|
|
250
|
+
const rec = cmapOffset + 4 + i * 8;
|
|
251
|
+
const platform = u16(buf, rec);
|
|
252
|
+
const encoding = u16(buf, rec + 2);
|
|
253
|
+
const offset = cmapOffset + u32(buf, rec + 4);
|
|
254
|
+
const format = u16(buf, offset);
|
|
255
|
+
if (format === 12 && (platform === 3 || platform === 0)) format12 = offset;
|
|
256
|
+
if (format === 4 && (platform === 3 || platform === 0) && encoding <= 1) {
|
|
257
|
+
format4 = offset;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
if (format12 >= 0) {
|
|
261
|
+
const nGroups = u32(buf, format12 + 12);
|
|
262
|
+
const groups = [];
|
|
263
|
+
for (let i = 0; i < nGroups; i += 1) {
|
|
264
|
+
const o = format12 + 16 + i * 12;
|
|
265
|
+
groups.push({
|
|
266
|
+
start: u32(buf, o),
|
|
267
|
+
end: u32(buf, o + 4),
|
|
268
|
+
glyph: u32(buf, o + 8)
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
return (code) => {
|
|
272
|
+
for (const g of groups) {
|
|
273
|
+
if (code >= g.start && code <= g.end) return g.glyph + (code - g.start);
|
|
274
|
+
}
|
|
275
|
+
return 0;
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
if (format4 < 0) {
|
|
279
|
+
return () => 0;
|
|
280
|
+
}
|
|
281
|
+
const segCount = u16(buf, format4 + 6) / 2;
|
|
282
|
+
const endCodes = format4 + 14;
|
|
283
|
+
const startCodes = endCodes + 2 + segCount * 2;
|
|
284
|
+
const idDeltas = startCodes + segCount * 2;
|
|
285
|
+
const idRangeOffsets = idDeltas + segCount * 2;
|
|
286
|
+
return (code) => {
|
|
287
|
+
for (let i = 0; i < segCount; i += 1) {
|
|
288
|
+
const end = u16(buf, endCodes + i * 2);
|
|
289
|
+
if (code > end) continue;
|
|
290
|
+
const start = u16(buf, startCodes + i * 2);
|
|
291
|
+
if (code < start) return 0;
|
|
292
|
+
const rangeOffset = u16(buf, idRangeOffsets + i * 2);
|
|
293
|
+
const delta = i16(buf, idDeltas + i * 2);
|
|
294
|
+
if (rangeOffset === 0) return code + delta & 65535;
|
|
295
|
+
const glyphOffset = idRangeOffsets + i * 2 + rangeOffset + (code - start) * 2;
|
|
296
|
+
const glyph = u16(buf, glyphOffset);
|
|
297
|
+
if (glyph === 0) return 0;
|
|
298
|
+
return glyph + delta & 65535;
|
|
299
|
+
}
|
|
300
|
+
return 0;
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
function parseTtf(bytes) {
|
|
304
|
+
const tables = tableMap(bytes);
|
|
305
|
+
const head = tables.get("head");
|
|
306
|
+
const hhea = tables.get("hhea");
|
|
307
|
+
const hmtx = tables.get("hmtx");
|
|
308
|
+
const maxp = tables.get("maxp");
|
|
309
|
+
const cmap = tables.get("cmap");
|
|
310
|
+
if (!head || !hhea || !hmtx || !maxp || !cmap) {
|
|
311
|
+
throw new Error("VAZIRMATN_TTF_TABLES");
|
|
312
|
+
}
|
|
313
|
+
const unitsPerEm = u16(bytes, head.offset + 18);
|
|
314
|
+
const metrics = {
|
|
315
|
+
unitsPerEm,
|
|
316
|
+
xMin: i16(bytes, head.offset + 36),
|
|
317
|
+
yMin: i16(bytes, head.offset + 38),
|
|
318
|
+
xMax: i16(bytes, head.offset + 40),
|
|
319
|
+
yMax: i16(bytes, head.offset + 42),
|
|
320
|
+
ascent: i16(bytes, hhea.offset + 4),
|
|
321
|
+
descent: i16(bytes, hhea.offset + 6),
|
|
322
|
+
italicAngle: 0,
|
|
323
|
+
numGlyphs: u16(bytes, maxp.offset + 4)
|
|
324
|
+
};
|
|
325
|
+
const numberOfHMetrics = u16(bytes, hhea.offset + 34);
|
|
326
|
+
const advances = new Uint16Array(metrics.numGlyphs);
|
|
327
|
+
for (let i = 0; i < numberOfHMetrics; i += 1) {
|
|
328
|
+
advances[i] = u16(bytes, hmtx.offset + i * 4);
|
|
329
|
+
}
|
|
330
|
+
const lastAdvance = advances[numberOfHMetrics - 1] ?? metrics.unitsPerEm;
|
|
331
|
+
for (let i = numberOfHMetrics; i < metrics.numGlyphs; i += 1) {
|
|
332
|
+
advances[i] = lastAdvance;
|
|
333
|
+
}
|
|
334
|
+
const glyphId = parseCmap(bytes, cmap.offset);
|
|
335
|
+
return {
|
|
336
|
+
bytes,
|
|
337
|
+
metrics,
|
|
338
|
+
glyphId,
|
|
339
|
+
advance: (gid) => advances[gid] ?? lastAdvance
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
function pdfWidth(advance, unitsPerEm) {
|
|
343
|
+
return advance * 1e3 / unitsPerEm;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// packages/plugins/pdf/src/shapeRtl.ts
|
|
347
|
+
var FORMS = {
|
|
348
|
+
1575: [65165, 65166, 65165, 65166],
|
|
349
|
+
1576: [65167, 65168, 65169, 65170],
|
|
350
|
+
1662: [64342, 64343, 64344, 64345],
|
|
351
|
+
1578: [65173, 65174, 65175, 65176],
|
|
352
|
+
1579: [65177, 65178, 65179, 65180],
|
|
353
|
+
1580: [65181, 65182, 65183, 65184],
|
|
354
|
+
1670: [64378, 64379, 64380, 64381],
|
|
355
|
+
1581: [65185, 65186, 65187, 65188],
|
|
356
|
+
1582: [65189, 65190, 65191, 65192],
|
|
357
|
+
1583: [65193, 65194, 65193, 65194],
|
|
358
|
+
1584: [65195, 65196, 65195, 65196],
|
|
359
|
+
1585: [65197, 65198, 65197, 65198],
|
|
360
|
+
1586: [65199, 65200, 65199, 65200],
|
|
361
|
+
1688: [64394, 64395, 64394, 64395],
|
|
362
|
+
1587: [65201, 65202, 65203, 65204],
|
|
363
|
+
1588: [65205, 65206, 65207, 65208],
|
|
364
|
+
1589: [65209, 65210, 65211, 65212],
|
|
365
|
+
1590: [65213, 65214, 65215, 65216],
|
|
366
|
+
1591: [65217, 65218, 65219, 65220],
|
|
367
|
+
1592: [65221, 65222, 65223, 65224],
|
|
368
|
+
1593: [65225, 65226, 65227, 65228],
|
|
369
|
+
1594: [65229, 65230, 65231, 65232],
|
|
370
|
+
1601: [65233, 65234, 65235, 65236],
|
|
371
|
+
1602: [65237, 65238, 65239, 65240],
|
|
372
|
+
1705: [64398, 64399, 64400, 64401],
|
|
373
|
+
1603: [65241, 65242, 65243, 65244],
|
|
374
|
+
1711: [64402, 64403, 64404, 64405],
|
|
375
|
+
1604: [65245, 65246, 65247, 65248],
|
|
376
|
+
1605: [65249, 65250, 65251, 65252],
|
|
377
|
+
1606: [65253, 65254, 65255, 65256],
|
|
378
|
+
1607: [65257, 65258, 65259, 65260],
|
|
379
|
+
1608: [65261, 65262, 65261, 65262],
|
|
380
|
+
1740: [64508, 64509, 64510, 64511],
|
|
381
|
+
1610: [65265, 65266, 65267, 65268],
|
|
382
|
+
1570: [65153, 65154, 65153, 65154],
|
|
383
|
+
1577: [65171, 65172, 65171, 65172]
|
|
384
|
+
};
|
|
385
|
+
var RIGHT_ONLY = /* @__PURE__ */ new Set([
|
|
386
|
+
1570,
|
|
387
|
+
1575,
|
|
388
|
+
1577,
|
|
389
|
+
1583,
|
|
390
|
+
1584,
|
|
391
|
+
1585,
|
|
392
|
+
1586,
|
|
393
|
+
1688,
|
|
394
|
+
1608
|
|
395
|
+
]);
|
|
396
|
+
function canConnect(cp, side) {
|
|
397
|
+
if (!FORMS[cp]) return false;
|
|
398
|
+
if (RIGHT_ONLY.has(cp)) return side === "right";
|
|
399
|
+
return true;
|
|
400
|
+
}
|
|
401
|
+
function isLetter(cp) {
|
|
402
|
+
return cp in FORMS;
|
|
403
|
+
}
|
|
404
|
+
function shapeArabic(input) {
|
|
405
|
+
const cps = [...input].map((ch) => ch.codePointAt(0) ?? 0);
|
|
406
|
+
const out = [];
|
|
407
|
+
for (let i = 0; i < cps.length; i += 1) {
|
|
408
|
+
const cp = cps[i] ?? 0;
|
|
409
|
+
const forms = FORMS[cp];
|
|
410
|
+
if (!forms) {
|
|
411
|
+
out.push(cp);
|
|
412
|
+
continue;
|
|
413
|
+
}
|
|
414
|
+
let prev = i - 1;
|
|
415
|
+
while (prev >= 0 && (cps[prev] === 1600 || cps[prev] === 8204)) prev -= 1;
|
|
416
|
+
let next = i + 1;
|
|
417
|
+
while (next < cps.length && (cps[next] === 1600 || cps[next] === 8205)) next += 1;
|
|
418
|
+
const joinsPrev = prev >= 0 && isLetter(cps[prev] ?? 0) && canConnect(cps[prev] ?? 0, "left");
|
|
419
|
+
const joinsNext = next < cps.length && isLetter(cps[next] ?? 0) && canConnect(cp, "left");
|
|
420
|
+
const form = joinsPrev && joinsNext ? 3 : joinsNext ? 2 : joinsPrev ? 1 : 0;
|
|
421
|
+
out.push(forms[form] ?? cp);
|
|
422
|
+
}
|
|
423
|
+
return String.fromCodePoint(...out);
|
|
424
|
+
}
|
|
425
|
+
var LTR_RE = /^[0-9A-Za-z۰-۹.,:%/+-]+$/;
|
|
426
|
+
function reverseGraphemes(s) {
|
|
427
|
+
return [...s].reverse().join("");
|
|
428
|
+
}
|
|
429
|
+
function rtlVisual(input) {
|
|
430
|
+
const shaped = shapeArabic(input);
|
|
431
|
+
const parts = shaped.split(/([0-9A-Za-z۰-۹.,:%/+-]+)/);
|
|
432
|
+
const visual = [];
|
|
433
|
+
for (let i = parts.length - 1; i >= 0; i -= 1) {
|
|
434
|
+
const part = parts[i] ?? "";
|
|
435
|
+
if (!part) continue;
|
|
436
|
+
visual.push(LTR_RE.test(part) ? part : reverseGraphemes(part));
|
|
437
|
+
}
|
|
438
|
+
return visual.join("");
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
// packages/plugins/pdf/src/VazirmatnPdfRenderer.ts
|
|
442
|
+
var PAGE_W = 595;
|
|
443
|
+
var PAGE_H = 842;
|
|
444
|
+
var MARGIN = 36;
|
|
445
|
+
var TITLE_SIZE = 12;
|
|
446
|
+
var SUB_SIZE = 9;
|
|
447
|
+
var CELL_SIZE = 8;
|
|
448
|
+
var ROW_H = 16;
|
|
449
|
+
var HEADER_H = 18;
|
|
450
|
+
var FOOTER_H = 22;
|
|
451
|
+
var SIGN_H = 56;
|
|
452
|
+
function cellText(raw, fieldType) {
|
|
453
|
+
if (fieldType === "checkbox") {
|
|
454
|
+
return raw ? "\u0628\u0644\u0647" : "\u062E\u06CC\u0631";
|
|
455
|
+
}
|
|
456
|
+
return chunkF6EMC75A_cjs.formatExportValue(raw, fieldType);
|
|
457
|
+
}
|
|
458
|
+
function measure(font, text, size) {
|
|
459
|
+
let w = 0;
|
|
460
|
+
for (const ch of text) {
|
|
461
|
+
const cp = ch.codePointAt(0) ?? 0;
|
|
462
|
+
const gid = font.glyphId(cp);
|
|
463
|
+
w += pdfWidth(font.advance(gid), font.metrics.unitsPerEm);
|
|
464
|
+
}
|
|
465
|
+
return w * size / 1e3;
|
|
466
|
+
}
|
|
467
|
+
function fitText(font, text, size, maxWidth) {
|
|
468
|
+
if (measure(font, text, size) <= maxWidth) return text;
|
|
469
|
+
const ellipsis = "...";
|
|
470
|
+
let lo = 0;
|
|
471
|
+
let hi = [...text].length;
|
|
472
|
+
while (lo < hi) {
|
|
473
|
+
const mid = Math.ceil((lo + hi) / 2);
|
|
474
|
+
const slice = [...text].slice(0, mid).join("") + ellipsis;
|
|
475
|
+
if (measure(font, slice, size) <= maxWidth) lo = mid;
|
|
476
|
+
else hi = mid - 1;
|
|
477
|
+
}
|
|
478
|
+
if (lo <= 0) return ellipsis;
|
|
479
|
+
return [...text].slice(0, lo).join("") + ellipsis;
|
|
480
|
+
}
|
|
481
|
+
function toGids(font, text) {
|
|
482
|
+
const gids = [];
|
|
483
|
+
for (const ch of text) {
|
|
484
|
+
const cp = ch.codePointAt(0) ?? 0;
|
|
485
|
+
gids.push(font.glyphId(cp));
|
|
486
|
+
}
|
|
487
|
+
return gids;
|
|
488
|
+
}
|
|
489
|
+
function toUnicodeCmap(pairs) {
|
|
490
|
+
const unique = /* @__PURE__ */ new Map();
|
|
491
|
+
for (const p of pairs) {
|
|
492
|
+
if (!unique.has(p.gid)) unique.set(p.gid, p.unicode);
|
|
493
|
+
}
|
|
494
|
+
const entries = [...unique.entries()];
|
|
495
|
+
const chunks = [];
|
|
496
|
+
for (let i = 0; i < entries.length; i += 100) {
|
|
497
|
+
const slice = entries.slice(i, i + 100);
|
|
498
|
+
chunks.push(`${slice.length} beginbfchar`);
|
|
499
|
+
for (const [gid, uni] of slice) {
|
|
500
|
+
const g = gid.toString(16).padStart(4, "0");
|
|
501
|
+
const u = uni.toString(16).padStart(uni > 65535 ? 8 : 4, "0");
|
|
502
|
+
chunks.push(`<${g}> <${u}>`);
|
|
503
|
+
}
|
|
504
|
+
chunks.push("endbfchar");
|
|
505
|
+
}
|
|
506
|
+
return `%!PS-Adobe-3.0 Resource-CMap
|
|
507
|
+
%%BeginResource: CMap (Vazirmatn-UCS)
|
|
508
|
+
/CIDInit /ProcSet findresource begin
|
|
509
|
+
12 dict begin
|
|
510
|
+
begincmap
|
|
511
|
+
/CIDSystemInfo << /Registry (Adobe) /Ordering (UCS) /Supplement 0 >> def
|
|
512
|
+
/CMapName /Vazirmatn-UCS def
|
|
513
|
+
/CMapType 2 def
|
|
514
|
+
1 begincodespacerange
|
|
515
|
+
<0000> <FFFF>
|
|
516
|
+
endcodespacerange
|
|
517
|
+
${chunks.join("\n")}
|
|
518
|
+
endcmap
|
|
519
|
+
CMapName currentdict /CMap defineresource pop
|
|
520
|
+
end
|
|
521
|
+
end
|
|
522
|
+
%%EndResource
|
|
523
|
+
`;
|
|
524
|
+
}
|
|
525
|
+
function toSumNumber(raw) {
|
|
526
|
+
if (typeof raw === "number" && Number.isFinite(raw)) return Math.trunc(raw);
|
|
527
|
+
if (typeof raw === "bigint") {
|
|
528
|
+
const n = Number(raw);
|
|
529
|
+
return Number.isSafeInteger(n) ? n : null;
|
|
530
|
+
}
|
|
531
|
+
if (typeof raw === "string") {
|
|
532
|
+
const n = Number(
|
|
533
|
+
raw.trim().replace(/[۰-۹]/g, (d) => String("\u06F0\u06F1\u06F2\u06F3\u06F4\u06F5\u06F6\u06F7\u06F8\u06F9".indexOf(d))).replace(/,/g, "")
|
|
534
|
+
);
|
|
535
|
+
return Number.isFinite(n) ? Math.trunc(n) : null;
|
|
536
|
+
}
|
|
537
|
+
return null;
|
|
538
|
+
}
|
|
539
|
+
function readJpegSize(bytes) {
|
|
540
|
+
if (bytes.length < 4 || bytes[0] !== 255 || bytes[1] !== 216) return null;
|
|
541
|
+
let i = 2;
|
|
542
|
+
while (i + 9 < bytes.length) {
|
|
543
|
+
if (bytes[i] !== 255) {
|
|
544
|
+
i += 1;
|
|
545
|
+
continue;
|
|
546
|
+
}
|
|
547
|
+
const marker = bytes[i + 1];
|
|
548
|
+
const len = bytes[i + 2] << 8 | bytes[i + 3];
|
|
549
|
+
if (marker === 192 || marker === 193 || marker === 194) {
|
|
550
|
+
const h = bytes[i + 5] << 8 | bytes[i + 6];
|
|
551
|
+
const w = bytes[i + 7] << 8 | bytes[i + 8];
|
|
552
|
+
return { w, h };
|
|
553
|
+
}
|
|
554
|
+
i += 2 + len;
|
|
555
|
+
}
|
|
556
|
+
return null;
|
|
557
|
+
}
|
|
558
|
+
var VazirmatnPdfRenderer = class {
|
|
559
|
+
constructor(fontBytes) {
|
|
560
|
+
this.fontBytes = fontBytes;
|
|
561
|
+
if (!fontBytes?.byteLength) {
|
|
562
|
+
throw new Error(
|
|
563
|
+
"VazirmatnPdfRenderer requires font bytes from persian-data-grid/plugins/pdf/fonts/vazirmatn"
|
|
564
|
+
);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
async render(source, options) {
|
|
568
|
+
const font = parseTtf(this.fontBytes);
|
|
569
|
+
const rtl = options?.direction !== "ltr";
|
|
570
|
+
const template = options?.template;
|
|
571
|
+
const title = template?.header?.title ?? options?.title ?? "\u0627\u0642\u0644\u0627\u0645 \u0633\u0646\u062F";
|
|
572
|
+
const columns = source.columns.filter((c) => c.fieldName !== "index");
|
|
573
|
+
const colCount = Math.max(1, columns.length);
|
|
574
|
+
const tableWidth = PAGE_W - MARGIN * 2;
|
|
575
|
+
const colW = tableWidth / colCount;
|
|
576
|
+
const used = [];
|
|
577
|
+
const note = (text) => {
|
|
578
|
+
const visual = rtl ? rtlVisual(text) : text;
|
|
579
|
+
for (const ch of visual) {
|
|
580
|
+
const cp = ch.codePointAt(0) ?? 0;
|
|
581
|
+
used.push({ gid: font.glyphId(cp), unicode: cp });
|
|
582
|
+
}
|
|
583
|
+
return visual;
|
|
584
|
+
};
|
|
585
|
+
const titleVisual = note(title);
|
|
586
|
+
const subtitleVisual = template?.header?.subtitle ? note(template.header.subtitle) : null;
|
|
587
|
+
const metaVisuals = (template?.header?.meta ?? []).map((m) => note(m));
|
|
588
|
+
const footerTextVisual = template?.footer?.text ? note(template.footer.text) : null;
|
|
589
|
+
const pageFmt = template?.footer?.pageNumberFormat ?? "{page} / {pages}";
|
|
590
|
+
const showPageNumber = template != null && template.footer?.showPageNumber !== false;
|
|
591
|
+
const repeatHeader = template == null || template.repeatTableHeader !== false;
|
|
592
|
+
const totalsLabelVisual = template?.pageTotals ? note(template.pageTotals.label ?? "\u062C\u0645\u0639 \u0635\u0641\u062D\u0647") : null;
|
|
593
|
+
const signLabelVisual = template?.signature ? note(template.signature.label ?? "\u0627\u0645\u0636\u0627") : null;
|
|
594
|
+
const stampLabelVisual = template?.stamp ? note(template.stamp.label ?? "\u0645\u0647\u0631") : null;
|
|
595
|
+
note("0123456789 /");
|
|
596
|
+
const headers = columns.map(
|
|
597
|
+
(c) => note(c.fieldCaption ?? c.fieldName)
|
|
598
|
+
);
|
|
599
|
+
const body = source.rows.map(
|
|
600
|
+
(row) => columns.map((col) => {
|
|
601
|
+
const cell = row.cells[col.fieldName];
|
|
602
|
+
const raw = cell?.display ?? cell?.value ?? "";
|
|
603
|
+
return note(cellText(raw, col.fieldType));
|
|
604
|
+
})
|
|
605
|
+
);
|
|
606
|
+
const bodyNums = source.rows.map((row) => {
|
|
607
|
+
const map = /* @__PURE__ */ new Map();
|
|
608
|
+
for (const col of columns) {
|
|
609
|
+
const cell = row.cells[col.fieldName];
|
|
610
|
+
const raw = cell?.value ?? cell?.display ?? "";
|
|
611
|
+
map.set(col.fieldName, toSumNumber(raw));
|
|
612
|
+
}
|
|
613
|
+
return map;
|
|
614
|
+
});
|
|
615
|
+
let logoDrawW = template?.logo?.width ?? 64;
|
|
616
|
+
let logoDrawH = template?.logo?.height ?? 48;
|
|
617
|
+
if (template?.logo?.jpegBytes?.byteLength) {
|
|
618
|
+
const size = readJpegSize(template.logo.jpegBytes);
|
|
619
|
+
if (size && template.logo.height == null) {
|
|
620
|
+
logoDrawH = Math.round(logoDrawW * size.h / Math.max(1, size.w));
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
const headerBand = template ? Math.max(
|
|
624
|
+
logoDrawH,
|
|
625
|
+
28 + (subtitleVisual ? 14 : 0) + metaVisuals.length * 12
|
|
626
|
+
) + 12 : TITLE_SIZE + 16;
|
|
627
|
+
const footerBand = template && (footerTextVisual || showPageNumber) ? FOOTER_H + 8 : 0;
|
|
628
|
+
const signBand = template && (signLabelVisual || stampLabelVisual) ? SIGN_H + 8 : 0;
|
|
629
|
+
const totalsBand = template?.pageTotals ? ROW_H + 4 : 0;
|
|
630
|
+
const usable = (withSign) => PAGE_H - MARGIN * 2 - headerBand - footerBand - (repeatHeader ? HEADER_H : 0) - totalsBand - (withSign ? signBand : 0);
|
|
631
|
+
const pageRowCounts = [];
|
|
632
|
+
let remaining = body.length;
|
|
633
|
+
if (remaining === 0) {
|
|
634
|
+
pageRowCounts.push(0);
|
|
635
|
+
} else {
|
|
636
|
+
while (remaining > 0) {
|
|
637
|
+
const isLikelyLast = remaining <= Math.floor(usable(false) / ROW_H);
|
|
638
|
+
const budget = Math.max(
|
|
639
|
+
1,
|
|
640
|
+
Math.floor(usable(isLikelyLast && signBand > 0) / ROW_H)
|
|
641
|
+
);
|
|
642
|
+
const take = Math.min(remaining, budget);
|
|
643
|
+
pageRowCounts.push(take);
|
|
644
|
+
remaining -= take;
|
|
645
|
+
if (pageRowCounts.length > 1e4) break;
|
|
646
|
+
}
|
|
647
|
+
if (signBand > 0) {
|
|
648
|
+
const lastBudget = Math.max(1, Math.floor(usable(true) / ROW_H));
|
|
649
|
+
const lastIdx = pageRowCounts.length - 1;
|
|
650
|
+
if ((pageRowCounts[lastIdx] ?? 0) > lastBudget) {
|
|
651
|
+
const overflow = (pageRowCounts[lastIdx] ?? 0) - lastBudget;
|
|
652
|
+
pageRowCounts[lastIdx] = lastBudget;
|
|
653
|
+
pageRowCounts.push(overflow);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
const pageCount = Math.max(1, pageRowCounts.length);
|
|
658
|
+
const pageLabels = Array.from(
|
|
659
|
+
{ length: pageCount },
|
|
660
|
+
(_, p) => note(
|
|
661
|
+
pageFmt.replace("{page}", String(p + 1)).replace("{pages}", String(pageCount))
|
|
662
|
+
)
|
|
663
|
+
);
|
|
664
|
+
const pageTotalCells = pageRowCounts.map((take, p) => {
|
|
665
|
+
if (!template?.pageTotals || !totalsLabelVisual) return [];
|
|
666
|
+
const start = pageRowCounts.slice(0, p).reduce((a, n) => a + n, 0);
|
|
667
|
+
const numSlice = bodyNums.slice(start, start + take);
|
|
668
|
+
const sums = /* @__PURE__ */ new Map();
|
|
669
|
+
for (const colId of template.pageTotals.columns) {
|
|
670
|
+
let s = 0;
|
|
671
|
+
for (const row of numSlice) {
|
|
672
|
+
const n = row.get(colId);
|
|
673
|
+
if (n != null) s += n;
|
|
674
|
+
}
|
|
675
|
+
sums.set(colId, s);
|
|
676
|
+
}
|
|
677
|
+
return columns.map((col, colIdx) => {
|
|
678
|
+
const isTotalCol = template.pageTotals.columns.includes(col.fieldName);
|
|
679
|
+
if (isTotalCol) return note(String(sums.get(col.fieldName) ?? 0));
|
|
680
|
+
const labelCol = columns.findIndex(
|
|
681
|
+
(c) => !template.pageTotals.columns.includes(c.fieldName)
|
|
682
|
+
);
|
|
683
|
+
if (colIdx === (labelCol >= 0 ? labelCol : 0)) return totalsLabelVisual;
|
|
684
|
+
return "";
|
|
685
|
+
});
|
|
686
|
+
});
|
|
687
|
+
const metrics = font.metrics;
|
|
688
|
+
const scale = 1e3 / metrics.unitsPerEm;
|
|
689
|
+
const bbox = [
|
|
690
|
+
Math.round(metrics.xMin * scale),
|
|
691
|
+
Math.round(metrics.yMin * scale),
|
|
692
|
+
Math.round(metrics.xMax * scale),
|
|
693
|
+
Math.round(metrics.yMax * scale)
|
|
694
|
+
];
|
|
695
|
+
const ascent = Math.round(metrics.ascent * scale);
|
|
696
|
+
const descent = Math.round(metrics.descent * scale);
|
|
697
|
+
const usedGids = [...new Set(used.map((u) => u.gid))].sort((a, b) => a - b);
|
|
698
|
+
const wParts = usedGids.map((gid) => {
|
|
699
|
+
const w = Math.round(pdfWidth(font.advance(gid), metrics.unitsPerEm));
|
|
700
|
+
return `${gid} [${w}]`;
|
|
701
|
+
});
|
|
702
|
+
const pdf = new PdfBuilder();
|
|
703
|
+
pdf.addAscii("<< /Type /Catalog /Pages 2 0 R >>\n");
|
|
704
|
+
const pagesObj = 2;
|
|
705
|
+
pdf.addAscii("<< /Type /Pages /Kids [] /Count 0 >>\n");
|
|
706
|
+
const fontFile = pdf.addFlate(
|
|
707
|
+
font.bytes,
|
|
708
|
+
`/Length1 ${font.bytes.length} `
|
|
709
|
+
);
|
|
710
|
+
const descriptor = pdf.addAscii(
|
|
711
|
+
`<< /Type /FontDescriptor /FontName /Vazirmatn /Flags 32 /FontBBox [${bbox.join(" ")}] /ItalicAngle 0 /Ascent ${ascent} /Descent ${descent} /CapHeight ${ascent} /StemV 80 /FontFile2 ${fontFile} 0 R >>
|
|
712
|
+
`
|
|
713
|
+
);
|
|
714
|
+
const cidFont = pdf.addAscii(
|
|
715
|
+
`<< /Type /Font /Subtype /CIDFontType2 /BaseFont /Vazirmatn /CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >> /FontDescriptor ${descriptor} 0 R /DW 500 /W [${wParts.join(" ")}] /CIDToGIDMap /Identity >>
|
|
716
|
+
`
|
|
717
|
+
);
|
|
718
|
+
const toUnicode = pdf.addFlate(
|
|
719
|
+
new TextEncoder().encode(toUnicodeCmap(used))
|
|
720
|
+
);
|
|
721
|
+
const type0 = pdf.addAscii(
|
|
722
|
+
`<< /Type /Font /Subtype /Type0 /BaseFont /Vazirmatn /Encoding /Identity-H /DescendantFonts [${cidFont} 0 R] /ToUnicode ${toUnicode} 0 R >>
|
|
723
|
+
`
|
|
724
|
+
);
|
|
725
|
+
let logoXObject = null;
|
|
726
|
+
if (template?.logo?.jpegBytes?.byteLength) {
|
|
727
|
+
const jpeg = template.logo.jpegBytes;
|
|
728
|
+
const size = readJpegSize(jpeg) ?? { w: logoDrawW, h: logoDrawH };
|
|
729
|
+
logoXObject = pdf.addRawStream(
|
|
730
|
+
jpeg,
|
|
731
|
+
`<< /Type /XObject /Subtype /Image /Width ${size.w} /Height ${size.h} /ColorSpace /DeviceRGB /BitsPerComponent 8 /Filter /DCTDecode /Length ${jpeg.length} >>`
|
|
732
|
+
);
|
|
733
|
+
}
|
|
734
|
+
const pageObjNums = [];
|
|
735
|
+
const drawText = (ops, text, size, x, y) => {
|
|
736
|
+
ops.push("BT");
|
|
737
|
+
ops.push(`/F1 ${size} Tf`);
|
|
738
|
+
ops.push(`${x.toFixed(2)} ${y.toFixed(2)} Td`);
|
|
739
|
+
ops.push(`<${pdfEscapeTextHex(toGids(font, text))}> Tj`);
|
|
740
|
+
ops.push("ET");
|
|
741
|
+
};
|
|
742
|
+
const drawCell = (ops, col, top, height, text, header) => {
|
|
743
|
+
const x = rtl ? PAGE_W - MARGIN - (col + 1) * colW : MARGIN + col * colW;
|
|
744
|
+
if (header) {
|
|
745
|
+
ops.push("0.92 g");
|
|
746
|
+
ops.push(
|
|
747
|
+
`${x.toFixed(2)} ${(top - height).toFixed(2)} ${colW.toFixed(2)} ${height.toFixed(2)} re f`
|
|
748
|
+
);
|
|
749
|
+
ops.push("0 g");
|
|
750
|
+
}
|
|
751
|
+
ops.push("0.55 w 0.35 g");
|
|
752
|
+
ops.push(
|
|
753
|
+
`${x.toFixed(2)} ${(top - height).toFixed(2)} ${colW.toFixed(2)} ${height.toFixed(2)} re S`
|
|
754
|
+
);
|
|
755
|
+
ops.push("0 g");
|
|
756
|
+
if (!text) return;
|
|
757
|
+
const fitted = fitText(font, text, CELL_SIZE, colW - 6);
|
|
758
|
+
const tw = measure(font, fitted, CELL_SIZE);
|
|
759
|
+
const tx = rtl ? x + colW - 3 - tw : x + 3;
|
|
760
|
+
const ty = top - height + 4.5;
|
|
761
|
+
drawText(ops, fitted, CELL_SIZE, tx, ty);
|
|
762
|
+
};
|
|
763
|
+
let rowCursor = 0;
|
|
764
|
+
for (let p = 0; p < pageCount; p += 1) {
|
|
765
|
+
const ops = [];
|
|
766
|
+
const isLast = p === pageCount - 1;
|
|
767
|
+
let y = PAGE_H - MARGIN;
|
|
768
|
+
if (template) {
|
|
769
|
+
if (logoXObject != null) {
|
|
770
|
+
const lx = rtl ? PAGE_W - MARGIN - logoDrawW : MARGIN;
|
|
771
|
+
const ly = y - logoDrawH;
|
|
772
|
+
ops.push("q");
|
|
773
|
+
ops.push(
|
|
774
|
+
`${logoDrawW} 0 0 ${logoDrawH} ${lx.toFixed(2)} ${ly.toFixed(2)} cm /Im1 Do`
|
|
775
|
+
);
|
|
776
|
+
ops.push("Q");
|
|
777
|
+
}
|
|
778
|
+
const textOriginX = rtl ? PAGE_W - MARGIN - (logoXObject != null ? logoDrawW + 10 : 0) : MARGIN + (logoXObject != null ? logoDrawW + 10 : 0);
|
|
779
|
+
let ty = y - 12;
|
|
780
|
+
const tw = measure(font, titleVisual, TITLE_SIZE);
|
|
781
|
+
drawText(
|
|
782
|
+
ops,
|
|
783
|
+
titleVisual,
|
|
784
|
+
TITLE_SIZE,
|
|
785
|
+
rtl ? textOriginX - tw : textOriginX,
|
|
786
|
+
ty
|
|
787
|
+
);
|
|
788
|
+
ty -= 14;
|
|
789
|
+
if (subtitleVisual) {
|
|
790
|
+
const sw = measure(font, subtitleVisual, SUB_SIZE);
|
|
791
|
+
drawText(
|
|
792
|
+
ops,
|
|
793
|
+
subtitleVisual,
|
|
794
|
+
SUB_SIZE,
|
|
795
|
+
rtl ? textOriginX - sw : textOriginX,
|
|
796
|
+
ty
|
|
797
|
+
);
|
|
798
|
+
ty -= 12;
|
|
799
|
+
}
|
|
800
|
+
for (const meta of metaVisuals) {
|
|
801
|
+
const mw = measure(font, meta, SUB_SIZE);
|
|
802
|
+
drawText(
|
|
803
|
+
ops,
|
|
804
|
+
meta,
|
|
805
|
+
SUB_SIZE,
|
|
806
|
+
rtl ? textOriginX - mw : textOriginX,
|
|
807
|
+
ty
|
|
808
|
+
);
|
|
809
|
+
ty -= 12;
|
|
810
|
+
}
|
|
811
|
+
y = PAGE_H - MARGIN - headerBand;
|
|
812
|
+
} else {
|
|
813
|
+
const titleW = measure(font, titleVisual, TITLE_SIZE);
|
|
814
|
+
drawText(
|
|
815
|
+
ops,
|
|
816
|
+
titleVisual,
|
|
817
|
+
TITLE_SIZE,
|
|
818
|
+
rtl ? PAGE_W - MARGIN - titleW : MARGIN,
|
|
819
|
+
y - 12
|
|
820
|
+
);
|
|
821
|
+
y = PAGE_H - MARGIN - headerBand;
|
|
822
|
+
}
|
|
823
|
+
if (repeatHeader || p === 0) {
|
|
824
|
+
headers.forEach((h, col) => drawCell(ops, col, y, HEADER_H, h, true));
|
|
825
|
+
y -= HEADER_H;
|
|
826
|
+
}
|
|
827
|
+
const take = pageRowCounts[p] ?? 0;
|
|
828
|
+
const slice = body.slice(rowCursor, rowCursor + take);
|
|
829
|
+
for (const row of slice) {
|
|
830
|
+
row.forEach((cell, col) => drawCell(ops, col, y, ROW_H, cell, false));
|
|
831
|
+
y -= ROW_H;
|
|
832
|
+
}
|
|
833
|
+
const totalRow = pageTotalCells[p];
|
|
834
|
+
if (totalRow && totalRow.length > 0) {
|
|
835
|
+
totalRow.forEach(
|
|
836
|
+
(text, colIdx) => drawCell(ops, colIdx, y, ROW_H, text, true)
|
|
837
|
+
);
|
|
838
|
+
y -= ROW_H;
|
|
839
|
+
}
|
|
840
|
+
if (isLast && (signLabelVisual || stampLabelVisual)) {
|
|
841
|
+
const boxW = (tableWidth - 12) / 2;
|
|
842
|
+
const boxH = SIGN_H - 8;
|
|
843
|
+
const by = MARGIN + footerBand + 4;
|
|
844
|
+
const boxes = [];
|
|
845
|
+
if (rtl) {
|
|
846
|
+
if (signLabelVisual) {
|
|
847
|
+
boxes.push({ label: signLabelVisual, x: PAGE_W - MARGIN - boxW });
|
|
848
|
+
}
|
|
849
|
+
if (stampLabelVisual) {
|
|
850
|
+
boxes.push({
|
|
851
|
+
label: stampLabelVisual,
|
|
852
|
+
x: PAGE_W - MARGIN - boxW * 2 - 12
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
} else {
|
|
856
|
+
if (signLabelVisual) boxes.push({ label: signLabelVisual, x: MARGIN });
|
|
857
|
+
if (stampLabelVisual) {
|
|
858
|
+
boxes.push({ label: stampLabelVisual, x: MARGIN + boxW + 12 });
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
for (const box of boxes) {
|
|
862
|
+
ops.push("0.55 w 0.35 g");
|
|
863
|
+
ops.push(
|
|
864
|
+
`${box.x.toFixed(2)} ${by.toFixed(2)} ${boxW.toFixed(2)} ${boxH.toFixed(2)} re S`
|
|
865
|
+
);
|
|
866
|
+
ops.push("0 g");
|
|
867
|
+
const lw = measure(font, box.label, SUB_SIZE);
|
|
868
|
+
drawText(
|
|
869
|
+
ops,
|
|
870
|
+
box.label,
|
|
871
|
+
SUB_SIZE,
|
|
872
|
+
rtl ? box.x + boxW - 6 - lw : box.x + 6,
|
|
873
|
+
by + boxH - 14
|
|
874
|
+
);
|
|
875
|
+
const lineCount = template?.signature?.lines ?? 2;
|
|
876
|
+
for (let li = 0; li < lineCount; li += 1) {
|
|
877
|
+
const ly = by + 10 + li * 14;
|
|
878
|
+
ops.push("0.4 w 0.6 g");
|
|
879
|
+
ops.push(
|
|
880
|
+
`${(box.x + 8).toFixed(2)} ${ly.toFixed(2)} m ${(box.x + boxW - 8).toFixed(2)} ${ly.toFixed(2)} l S`
|
|
881
|
+
);
|
|
882
|
+
ops.push("0 g");
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
if (footerBand > 0) {
|
|
887
|
+
const fy = MARGIN + 6;
|
|
888
|
+
if (footerTextVisual) {
|
|
889
|
+
const fw = measure(font, footerTextVisual, SUB_SIZE);
|
|
890
|
+
drawText(
|
|
891
|
+
ops,
|
|
892
|
+
footerTextVisual,
|
|
893
|
+
SUB_SIZE,
|
|
894
|
+
rtl ? PAGE_W - MARGIN - fw : MARGIN,
|
|
895
|
+
fy
|
|
896
|
+
);
|
|
897
|
+
}
|
|
898
|
+
if (showPageNumber) {
|
|
899
|
+
const label = pageLabels[p];
|
|
900
|
+
const pw = measure(font, label, SUB_SIZE);
|
|
901
|
+
drawText(
|
|
902
|
+
ops,
|
|
903
|
+
label,
|
|
904
|
+
SUB_SIZE,
|
|
905
|
+
rtl ? MARGIN : PAGE_W - MARGIN - pw,
|
|
906
|
+
fy
|
|
907
|
+
);
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
const content = pdf.addFlate(
|
|
911
|
+
new TextEncoder().encode(ops.join("\n") + "\n")
|
|
912
|
+
);
|
|
913
|
+
const xobjRes = logoXObject != null ? `/XObject << /Im1 ${logoXObject} 0 R >>` : "";
|
|
914
|
+
const pageNo = pdf.addAscii(
|
|
915
|
+
`<< /Type /Page /Parent ${pagesObj} 0 R /MediaBox [0 0 ${PAGE_W} ${PAGE_H}] /Contents ${content} 0 R /Resources << /Font << /F1 ${type0} 0 R >> ${xobjRes} >> >>
|
|
916
|
+
`
|
|
917
|
+
);
|
|
918
|
+
pageObjNums.push(pageNo);
|
|
919
|
+
rowCursor += take;
|
|
920
|
+
}
|
|
921
|
+
const kids = pageObjNums.map((n) => `${n} 0 R`).join(" ");
|
|
922
|
+
pdf.replaceAscii(
|
|
923
|
+
pagesObj,
|
|
924
|
+
`<< /Type /Pages /Kids [${kids}] /Count ${pageObjNums.length} >>
|
|
925
|
+
`
|
|
926
|
+
);
|
|
927
|
+
const bytes = pdf.build();
|
|
928
|
+
return new Blob([bytes], { type: "application/pdf" });
|
|
929
|
+
}
|
|
930
|
+
};
|
|
931
|
+
|
|
932
|
+
exports.PdfExportPlugin = PdfExportPlugin;
|
|
933
|
+
exports.TextPdfRenderer = TextPdfRenderer;
|
|
934
|
+
exports.VazirmatnPdfRenderer = VazirmatnPdfRenderer;
|
|
935
|
+
//# sourceMappingURL=chunk-VYJQ2HTA.cjs.map
|
|
936
|
+
//# sourceMappingURL=chunk-VYJQ2HTA.cjs.map
|