abstract-document 6.2.0 → 6.4.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/CHANGELOG.md +13 -4
- package/LICENSE +21 -0
- package/lib/abstract-document/section-elements/table.d.ts +2 -0
- package/lib/abstract-document/section-elements/table.d.ts.map +1 -1
- package/lib/abstract-document/section-elements/table.js +2 -2
- package/lib/abstract-document/section-elements/table.js.map +1 -1
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/group-too-big-for-one-page.d.ts +3 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/group-too-big-for-one-page.d.ts.map +1 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/group-too-big-for-one-page.js +251 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/group-too-big-for-one-page.js.map +1 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-row-that-doesnt-fit-page.d.ts +3 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-row-that-doesnt-fit-page.d.ts.map +1 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-row-that-doesnt-fit-page.js +294 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-row-that-doesnt-fit-page.js.map +1 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-single-row.d.ts +3 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-single-row.d.ts.map +1 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-single-row.js +209 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-single-row.js.map +1 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-group.d.ts +3 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-group.d.ts.map +1 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-group.js +465 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-group.js.map +1 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-header.d.ts +3 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-header.d.ts.map +1 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-header.js +1529 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-header.js.map +1 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-header2.d.ts +3 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-header2.d.ts.map +1 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-header2.js +783 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-header2.js.map +1 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-margin-bottom.d.ts +3 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-margin-bottom.d.ts.map +1 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-margin-bottom.js +423 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-margin-bottom.js.map +1 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-margin-top-single-table.d.ts +3 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-margin-top-single-table.d.ts.map +1 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-margin-top-single-table.js +331 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-margin-top-single-table.js.map +1 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-margin-top.d.ts +3 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-margin-top.d.ts.map +1 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-margin-top.js +423 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-margin-top.js.map +1 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-margin.d.ts +3 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-margin.d.ts.map +1 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-margin.js +56 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-margin.js.map +1 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-rowSpan-multipages.d.ts +3 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-rowSpan-multipages.d.ts.map +1 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-rowSpan-multipages.js +1541 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-rowSpan-multipages.js.map +1 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-rowSpan.d.ts +3 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-rowSpan.d.ts.map +1 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-rowSpan.js +512 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-rowSpan.js.map +1 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/simple-table-with-header.d.ts +3 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/simple-table-with-header.d.ts.map +1 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/simple-table-with-header.js +460 -0
- package/lib/abstract-document-exporters/__tests__/pdf/test-defs/simple-table-with-header.js.map +1 -0
- package/lib/abstract-document-exporters/pdf/measure.d.ts +1 -0
- package/lib/abstract-document-exporters/pdf/measure.d.ts.map +1 -1
- package/lib/abstract-document-exporters/pdf/measure.js +5 -3
- package/lib/abstract-document-exporters/pdf/measure.js.map +1 -1
- package/lib/abstract-document-exporters/pdf/paginate.d.ts.map +1 -1
- package/lib/abstract-document-exporters/pdf/paginate.js +112 -25
- package/lib/abstract-document-exporters/pdf/paginate.js.map +1 -1
- package/lib/abstract-document-exporters/pdf/pre-process.d.ts.map +1 -1
- package/lib/abstract-document-exporters/pdf/pre-process.js +31 -27
- package/lib/abstract-document-exporters/pdf/pre-process.js.map +1 -1
- package/lib/abstract-document-exporters/pdf/render.js +4 -5
- package/lib/abstract-document-exporters/pdf/render.js.map +1 -1
- package/package.json +3 -2
- package/src/abstract-document/section-elements/table.ts +6 -11
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Group.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Header and footer.docx and b/package/src/abstract-document-exporters/__tests__/docx2/tmp/Header → footer.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Mixed hyperlink and textrun.docx and b/package/src/abstract-document-exporters/__tests__/docx2/tmp/Mixed hyperlink → textrun.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Mixed textrun and images.docx and b/package/src/abstract-document-exporters/__tests__/docx2/tmp/Mixed textrun → images.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Multiple images.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Multiple tables.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Multiple textrun with Center alignment.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Multiple textrun with End alignment.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Multiple textrun with Start alignment that linebreaks.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Multiple textrun with Start alignment.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Page numbering.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Simple table colSpan and rowSpan.docx and b/package/src/abstract-document-exporters/__tests__/docx2/tmp/Simple table colSpan → rowSpan.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Simple table without rows.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Simple table.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Single hyperlink.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Single image.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Single textrun with Center alignment that linebreaks.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Single textrun with Center alignment.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Single textrun with End alignment that linebreaks.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Single textrun with End alignment.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Single textrun with Start alignment that linebreaks.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Single textrun with Start alignment.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Single textrun.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/hello.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/world.docx +0 -0
- package/src/abstract-document-exporters/__tests__/pdf/test-defs/group-too-big-for-one-page.tsx +272 -0
- package/src/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-row-that-doesnt-fit-page.tsx +317 -0
- package/src/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-single-row.tsx +227 -0
- package/src/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-group.tsx +500 -0
- package/src/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-header.tsx +1555 -0
- package/src/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-header2.tsx +824 -0
- package/src/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-margin-bottom.tsx +455 -0
- package/src/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-margin-top-single-table.tsx +354 -0
- package/src/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-margin-top.tsx +455 -0
- package/src/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-rowSpan-multipages.tsx +1567 -0
- package/src/abstract-document-exporters/__tests__/pdf/test-defs/page-break-table-with-rowSpan.tsx +545 -0
- package/src/abstract-document-exporters/__tests__/pdf/test-defs/simple-table-with-header.tsx +482 -0
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Group Paragraphs.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Group Tables.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Group too big for one page.pdf +268 -0
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Header and footer.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Hyperlink internal linktarget.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Hyperlink internal.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Margins header body footer.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Mixed hyperlink and textrun.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Mixed textrun and images.pdf and b/package/src/abstract-document-exporters/__tests__/pdf/tmp/Mixed textrun → images.pdf +0 -0
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Multiple images overflow.pdf +0 -0
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Multiple images.pdf +0 -0
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Multiple textrun with Center alignment.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Multiple textrun with End alignment.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Multiple textrun with Start alignment that linebreaks.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Multiple textrun with Start alignment.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Page numbering.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Pagebreak table row that doesnt fit page.pdf +302 -0
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Pagebreak table single row.pdf +234 -0
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Pagebreak table with group.pdf +438 -0
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Pagebreak table with header 2.pdf +676 -0
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Pagebreak table with header.pdf +3833 -0
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Pagebreak table with margin bottom.pdf +404 -0
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Pagebreak table with margin top single table.pdf +336 -0
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Pagebreak table with margin top.pdf +404 -0
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Pagebreak table with margin.pdf +404 -0
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Pagebreak table with rowSpan multipages.pdf +3983 -0
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Pagebreak table with rowSpan.pdf +486 -0
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table all auto.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table all fix.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table background.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table cell padding of image.pdf +0 -0
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table cell padding of text.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table center alignment.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table colSpan and rowSpan.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table mix auto fix.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table padding.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table right alignment.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table row alignment.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table text alignment in cell with wrapping.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table text alignment in cell.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table with default colored borders.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table with header.pdf +409 -0
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table with multi colored borders.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table with single colored borders.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single date.pdf +14 -14
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single hyperlink centered.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single hyperlink right aligned.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single hyperlink.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single image svg color hex.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single image svg color name.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single image svg color url.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single image.pdf +0 -0
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single textrun with Center alignment that linebreaks.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single textrun with Center alignment.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single textrun with End alignment that linebreaks.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single textrun with End alignment.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single textrun with Justify alignment.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single textrun with Start alignment that linebreaks.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single textrun with Start alignment.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single textrun with super and subscripts.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single textrun.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Table of content separator.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/hello.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/world.pdf +2 -2
- package/src/abstract-document-exporters/pdf/measure.ts +4 -4
- package/src/abstract-document-exporters/pdf/paginate.ts +185 -89
- package/src/abstract-document-exporters/pdf/pre-process.ts +31 -35
- package/src/abstract-document-exporters/pdf/render.ts +4 -5
|
@@ -51,7 +51,7 @@ endobj
|
|
|
51
51
|
(PDFKit)
|
|
52
52
|
endobj
|
|
53
53
|
12 0 obj
|
|
54
|
-
(D:
|
|
54
|
+
(D:20211124154320Z)
|
|
55
55
|
endobj
|
|
56
56
|
9 0 obj
|
|
57
57
|
<<
|
|
@@ -114,7 +114,7 @@ trailer
|
|
|
114
114
|
/Size 13
|
|
115
115
|
/Root 3 0 R
|
|
116
116
|
/Info 9 0 R
|
|
117
|
-
/ID [<
|
|
117
|
+
/ID [<f9c7d6851ba22dd9411cbffa27098df3> <f9c7d6851ba22dd9411cbffa27098df3>]
|
|
118
118
|
>>
|
|
119
119
|
startxref
|
|
120
120
|
1418
|
package/src/abstract-document-exporters/__tests__/pdf/tmp/Single textrun with Start alignment.pdf
CHANGED
|
@@ -43,7 +43,7 @@ endobj
|
|
|
43
43
|
(PDFKit)
|
|
44
44
|
endobj
|
|
45
45
|
12 0 obj
|
|
46
|
-
(D:
|
|
46
|
+
(D:20211124154320Z)
|
|
47
47
|
endobj
|
|
48
48
|
9 0 obj
|
|
49
49
|
<<
|
|
@@ -106,7 +106,7 @@ trailer
|
|
|
106
106
|
/Size 13
|
|
107
107
|
/Root 3 0 R
|
|
108
108
|
/Info 9 0 R
|
|
109
|
-
/ID [<
|
|
109
|
+
/ID [<1515a889e1a7ab6c3b080842b51d9078> <1515a889e1a7ab6c3b080842b51d9078>]
|
|
110
110
|
>>
|
|
111
111
|
startxref
|
|
112
112
|
848
|
|
@@ -63,7 +63,7 @@ endobj
|
|
|
63
63
|
(PDFKit)
|
|
64
64
|
endobj
|
|
65
65
|
12 0 obj
|
|
66
|
-
(D:
|
|
66
|
+
(D:20211124154320Z)
|
|
67
67
|
endobj
|
|
68
68
|
9 0 obj
|
|
69
69
|
<<
|
|
@@ -126,7 +126,7 @@ trailer
|
|
|
126
126
|
/Size 13
|
|
127
127
|
/Root 3 0 R
|
|
128
128
|
/Info 9 0 R
|
|
129
|
-
/ID [<
|
|
129
|
+
/ID [<d5d827414bc4b7346a369cfecec66c25> <d5d827414bc4b7346a369cfecec66c25>]
|
|
130
130
|
>>
|
|
131
131
|
startxref
|
|
132
132
|
1076
|
|
@@ -43,7 +43,7 @@ endobj
|
|
|
43
43
|
(PDFKit)
|
|
44
44
|
endobj
|
|
45
45
|
12 0 obj
|
|
46
|
-
(D:
|
|
46
|
+
(D:20211124154320Z)
|
|
47
47
|
endobj
|
|
48
48
|
9 0 obj
|
|
49
49
|
<<
|
|
@@ -106,7 +106,7 @@ trailer
|
|
|
106
106
|
/Size 13
|
|
107
107
|
/Root 3 0 R
|
|
108
108
|
/Info 9 0 R
|
|
109
|
-
/ID [<
|
|
109
|
+
/ID [<ee0c991f78209c559ad2bf9290ab5cbd> <ee0c991f78209c559ad2bf9290ab5cbd>]
|
|
110
110
|
>>
|
|
111
111
|
startxref
|
|
112
112
|
824
|
|
@@ -84,7 +84,7 @@ endobj
|
|
|
84
84
|
(PDFKit)
|
|
85
85
|
endobj
|
|
86
86
|
15 0 obj
|
|
87
|
-
(D:
|
|
87
|
+
(D:20211124154320Z)
|
|
88
88
|
endobj
|
|
89
89
|
12 0 obj
|
|
90
90
|
<<
|
|
@@ -150,7 +150,7 @@ trailer
|
|
|
150
150
|
/Size 16
|
|
151
151
|
/Root 3 0 R
|
|
152
152
|
/Info 12 0 R
|
|
153
|
-
/ID [<
|
|
153
|
+
/ID [<e240d9002d21a37a30ebcd421fb986a3> <e240d9002d21a37a30ebcd421fb986a3>]
|
|
154
154
|
>>
|
|
155
155
|
startxref
|
|
156
156
|
1439
|
|
@@ -79,7 +79,7 @@ endobj
|
|
|
79
79
|
(PDFKit)
|
|
80
80
|
endobj
|
|
81
81
|
15 0 obj
|
|
82
|
-
(D:
|
|
82
|
+
(D:20211124154320Z)
|
|
83
83
|
endobj
|
|
84
84
|
12 0 obj
|
|
85
85
|
<<
|
|
@@ -145,7 +145,7 @@ trailer
|
|
|
145
145
|
/Size 16
|
|
146
146
|
/Root 3 0 R
|
|
147
147
|
/Info 12 0 R
|
|
148
|
-
/ID [<
|
|
148
|
+
/ID [<21816c3e20efc2272ef0b485514d10ea> <21816c3e20efc2272ef0b485514d10ea>]
|
|
149
149
|
>>
|
|
150
150
|
startxref
|
|
151
151
|
1212
|
|
@@ -43,7 +43,7 @@ endobj
|
|
|
43
43
|
(PDFKit)
|
|
44
44
|
endobj
|
|
45
45
|
12 0 obj
|
|
46
|
-
(D:
|
|
46
|
+
(D:20211124154320Z)
|
|
47
47
|
endobj
|
|
48
48
|
9 0 obj
|
|
49
49
|
<<
|
|
@@ -106,7 +106,7 @@ trailer
|
|
|
106
106
|
/Size 13
|
|
107
107
|
/Root 3 0 R
|
|
108
108
|
/Info 9 0 R
|
|
109
|
-
/ID [<
|
|
109
|
+
/ID [<b4e36add613f2271ddea1e998d10d746> <b4e36add613f2271ddea1e998d10d746>]
|
|
110
110
|
>>
|
|
111
111
|
startxref
|
|
112
112
|
837
|
|
@@ -176,7 +176,7 @@ function getBiggestStyle(
|
|
|
176
176
|
return textOptions;
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
function measureTable(
|
|
179
|
+
export function measureTable(
|
|
180
180
|
pdf: any,
|
|
181
181
|
resources: AD.Resources.Resources,
|
|
182
182
|
availableSize: AD.Size.Size,
|
|
@@ -195,8 +195,8 @@ function measureTable(
|
|
|
195
195
|
const infinityWidth = (tableAvailableWidth - fixedColumnsWidth) / numInfinityColumns;
|
|
196
196
|
const columnWidths = table.columnWidths.map((w) => (isFinite(w) ? w : infinityWidth));
|
|
197
197
|
const desiredSizes = new Map<any, AD.Size.Size>();
|
|
198
|
-
|
|
199
|
-
for (let row of
|
|
198
|
+
const rows = [...table.headerRows, ...table.children];
|
|
199
|
+
for (let row of rows) {
|
|
200
200
|
let column = 0;
|
|
201
201
|
for (let cell of row.children) {
|
|
202
202
|
const cellStyle = AD.Resources.getStyle(
|
|
@@ -229,7 +229,7 @@ function measureTable(
|
|
|
229
229
|
: table.columnWidths.reduce((a, b) => a + b, style.margins.left + style.margins.right);
|
|
230
230
|
|
|
231
231
|
let desiredHeight = style.margins.top + style.margins.bottom;
|
|
232
|
-
for (let row of
|
|
232
|
+
for (let row of rows) {
|
|
233
233
|
let rowHeight = row.children.map((c) => getDesiredSize(c, desiredSizes).height).reduce((a, b) => Math.max(a, b), 0);
|
|
234
234
|
desiredHeight += rowHeight;
|
|
235
235
|
desiredSizes.set(row, AD.Size.create(desiredWidth, rowHeight));
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import * as R from "ramda";
|
|
2
|
+
import { split } from "ramda";
|
|
2
3
|
import * as AD from "../../abstract-document/index";
|
|
4
|
+
import { Table } from "../../abstract-document/section-elements/table";
|
|
3
5
|
import { getResources } from "../shared/get_resources";
|
|
4
6
|
import { registerFonts } from "./font";
|
|
7
|
+
import { measureTable } from "./measure";
|
|
5
8
|
|
|
6
9
|
/* tslint:disable:no-any */
|
|
7
10
|
|
|
@@ -25,25 +28,23 @@ export function paginate(
|
|
|
25
28
|
let pdf = new pdfKit({
|
|
26
29
|
compress: false,
|
|
27
30
|
autoFirstPage: false,
|
|
28
|
-
bufferPages: true
|
|
31
|
+
bufferPages: true,
|
|
29
32
|
}) as any;
|
|
30
33
|
|
|
31
|
-
registerFonts(
|
|
32
|
-
(fontName: string, fontSource: AD.Font.FontSource) =>
|
|
33
|
-
pdf.registerFont(fontName, fontSource),
|
|
34
|
-
document
|
|
35
|
-
);
|
|
34
|
+
registerFonts((fontName: string, fontSource: AD.Font.FontSource) => pdf.registerFont(fontName, fontSource), document);
|
|
36
35
|
|
|
37
36
|
let pages = new Array<Page>();
|
|
38
37
|
for (let section of document.children) {
|
|
39
38
|
const previousPage = pages.length > 0 ? pages[pages.length - 1] : undefined;
|
|
40
|
-
pages.push(...splitSection(resources, desiredSizes, previousPage, section));
|
|
39
|
+
pages.push(...splitSection(pdfKit, document, resources, desiredSizes, previousPage, section));
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
return pages;
|
|
44
43
|
}
|
|
45
44
|
|
|
46
45
|
function splitSection(
|
|
46
|
+
pdfKit: any,
|
|
47
|
+
document: AD.AbstractDoc.AbstractDoc,
|
|
47
48
|
parentResources: AD.Resources.Resources,
|
|
48
49
|
desiredSizes: Map<{}, AD.Size.Size>,
|
|
49
50
|
previousPage: Page | undefined,
|
|
@@ -60,14 +61,7 @@ function splitSection(
|
|
|
60
61
|
for (let i = 0; i < children.length; ++i) {
|
|
61
62
|
const element = children[i];
|
|
62
63
|
if (element.type === "PageBreak") {
|
|
63
|
-
currentPage = createPage(
|
|
64
|
-
resources,
|
|
65
|
-
desiredSizes,
|
|
66
|
-
currentPage,
|
|
67
|
-
section,
|
|
68
|
-
elements,
|
|
69
|
-
pages.length === 0
|
|
70
|
-
);
|
|
64
|
+
currentPage = createPage(resources, desiredSizes, currentPage, section, elements, pages.length === 0);
|
|
71
65
|
pages.push(currentPage);
|
|
72
66
|
elements = [];
|
|
73
67
|
elementsHeight = 0;
|
|
@@ -75,13 +69,9 @@ function splitSection(
|
|
|
75
69
|
}
|
|
76
70
|
const elementSize = getDesiredSize(element, desiredSizes);
|
|
77
71
|
|
|
78
|
-
// Collapse groups
|
|
72
|
+
// Collapse groups that doesn't fit on empty page
|
|
79
73
|
if (elementSize.height > contentRect.height && element.type === "Group") {
|
|
80
|
-
children = [
|
|
81
|
-
...children.slice(0, i),
|
|
82
|
-
...element.children,
|
|
83
|
-
...children.slice(i + 1)
|
|
84
|
-
];
|
|
74
|
+
children = [...children.slice(0, i), ...element.children, ...children.slice(i + 1)];
|
|
85
75
|
i--;
|
|
86
76
|
continue;
|
|
87
77
|
}
|
|
@@ -89,25 +79,53 @@ function splitSection(
|
|
|
89
79
|
elements.push(element);
|
|
90
80
|
elementsHeight += elementSize.height;
|
|
91
81
|
|
|
92
|
-
const [leadingSpace, trailingSpace] = getLeadingAndTrailingSpace(
|
|
93
|
-
resources,
|
|
94
|
-
section,
|
|
95
|
-
elements
|
|
96
|
-
);
|
|
82
|
+
const [leadingSpace, trailingSpace] = getLeadingAndTrailingSpace(resources, section, elements);
|
|
97
83
|
const availableHeight = contentRect.height + leadingSpace + trailingSpace;
|
|
98
84
|
if (elementsHeight > availableHeight) {
|
|
85
|
+
if (element.type === "Table" && element.children.length > 1) {
|
|
86
|
+
//Remove last element
|
|
87
|
+
elements.pop();
|
|
88
|
+
elementsHeight -= elementSize.height;
|
|
89
|
+
|
|
90
|
+
//Try to split table
|
|
91
|
+
const [tableHead, tableTail] = splitTable(
|
|
92
|
+
pdfKit,
|
|
93
|
+
document,
|
|
94
|
+
resources,
|
|
95
|
+
desiredSizes,
|
|
96
|
+
element,
|
|
97
|
+
elementsHeight,
|
|
98
|
+
availableHeight,
|
|
99
|
+
elements.length
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const tableSplit: AD.Table.Table[] = [];
|
|
103
|
+
if (tableHead) {
|
|
104
|
+
elements.push(tableHead);
|
|
105
|
+
tableSplit.push(tableHead);
|
|
106
|
+
} else {
|
|
107
|
+
i--;
|
|
108
|
+
}
|
|
109
|
+
if (tableTail) {
|
|
110
|
+
tableSplit.push(tableTail);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
//Add split table to children to process tableTail in next iteration
|
|
114
|
+
children = [...children.slice(0, i), ...tableSplit, ...children.slice(i + 1)];
|
|
115
|
+
|
|
116
|
+
currentPage = createPage(resources, desiredSizes, currentPage, section, elements, pages.length === 0);
|
|
117
|
+
pages.push(currentPage);
|
|
118
|
+
elements = [];
|
|
119
|
+
elementsHeight = 0;
|
|
120
|
+
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
|
|
99
124
|
if (elements.length > 1) {
|
|
100
125
|
elements.pop();
|
|
101
126
|
i--;
|
|
102
127
|
}
|
|
103
|
-
currentPage = createPage(
|
|
104
|
-
resources,
|
|
105
|
-
desiredSizes,
|
|
106
|
-
currentPage,
|
|
107
|
-
section,
|
|
108
|
-
elements,
|
|
109
|
-
pages.length === 0
|
|
110
|
-
);
|
|
128
|
+
currentPage = createPage(resources, desiredSizes, currentPage, section, elements, pages.length === 0);
|
|
111
129
|
pages.push(currentPage);
|
|
112
130
|
elements = [];
|
|
113
131
|
elementsHeight = 0;
|
|
@@ -115,19 +133,66 @@ function splitSection(
|
|
|
115
133
|
}
|
|
116
134
|
|
|
117
135
|
if (elements.length > 0) {
|
|
118
|
-
pages.push(
|
|
119
|
-
|
|
136
|
+
pages.push(createPage(resources, desiredSizes, currentPage, section, elements, pages.length === 0));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return pages;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function splitTable(
|
|
143
|
+
pdfKit: any,
|
|
144
|
+
document: AD.AbstractDoc.AbstractDoc,
|
|
145
|
+
resources: AD.Resources.Resources,
|
|
146
|
+
desiredSizes: Map<{}, AD.Size.Size>,
|
|
147
|
+
table: AD.Table.Table,
|
|
148
|
+
elementsHeight: number,
|
|
149
|
+
availableHeight: number,
|
|
150
|
+
elementsLength: number
|
|
151
|
+
): [AD.Table.Table | undefined, AD.Table.Table | undefined] {
|
|
152
|
+
let tableHead = undefined;
|
|
153
|
+
let tableRest = undefined;
|
|
154
|
+
elementsHeight += table.style.margins.top || 0;
|
|
155
|
+
if (table.headerRows.length > 0) {
|
|
156
|
+
const headerSize = table.headerRows.reduce((acc, row) => (acc += getDesiredSize(row, desiredSizes).height), 0);
|
|
157
|
+
elementsHeight += headerSize;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
//Find where to split table
|
|
161
|
+
for (const [rowIndex, row] of table.children.entries()) {
|
|
162
|
+
const rowSize = getDesiredSize(row, desiredSizes);
|
|
163
|
+
elementsHeight += rowSize.height;
|
|
164
|
+
|
|
165
|
+
if (elementsHeight > availableHeight) {
|
|
166
|
+
if (rowIndex === 0 && elementsLength !== 0) {
|
|
167
|
+
//Not even first row fit on the page, shove it all to the next page
|
|
168
|
+
return [undefined, table];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const [newTableHead, newTableRest] = splitTableAt(
|
|
172
|
+
pdfKit,
|
|
173
|
+
document,
|
|
120
174
|
resources,
|
|
121
175
|
desiredSizes,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
)
|
|
127
|
-
|
|
176
|
+
table,
|
|
177
|
+
Math.max(rowIndex, 1)
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
if (newTableHead.children.length > 0) {
|
|
181
|
+
tableHead = newTableHead;
|
|
182
|
+
}
|
|
183
|
+
if (newTableRest.children.length > 0) {
|
|
184
|
+
tableRest = newTableRest;
|
|
185
|
+
}
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
128
188
|
}
|
|
129
189
|
|
|
130
|
-
|
|
190
|
+
if (!tableHead && !tableRest) {
|
|
191
|
+
//Didnt find a place to split the table, meaning the whole table fits on current page
|
|
192
|
+
return [table, undefined];
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return [tableHead, tableRest];
|
|
131
196
|
}
|
|
132
197
|
|
|
133
198
|
function createPage(
|
|
@@ -149,36 +214,22 @@ function createPage(
|
|
|
149
214
|
top: 0,
|
|
150
215
|
left: 0,
|
|
151
216
|
right: 0,
|
|
152
|
-
bottom: 0
|
|
153
|
-
}
|
|
217
|
+
bottom: 0,
|
|
218
|
+
},
|
|
154
219
|
};
|
|
155
220
|
const pageNo = previousPage ? previousPage.pageNo + 1 : 1;
|
|
156
221
|
|
|
157
222
|
const sectionName = isFirst && section.id !== "" ? [section.id] : [];
|
|
158
223
|
// For now, only support link targets at base level. Tree search would be needed to find all targets.
|
|
159
224
|
const targetNames = R.unnest(
|
|
160
|
-
elements.map(
|
|
161
|
-
|
|
162
|
-
e.type === "Paragraph"
|
|
163
|
-
? e.children.map(c => (c.type === "LinkTarget" ? c.name : ""))
|
|
164
|
-
: []
|
|
165
|
-
)
|
|
166
|
-
).filter(t => t !== "");
|
|
225
|
+
elements.map((e) => (e.type === "Paragraph" ? e.children.map((c) => (c.type === "LinkTarget" ? c.name : "")) : []))
|
|
226
|
+
).filter((t) => t !== "");
|
|
167
227
|
const namedDestionations = [...sectionName, ...targetNames];
|
|
168
228
|
|
|
169
229
|
// Ignore leading space by expanding the content rect upwards
|
|
170
230
|
const rect = getPageContentRect(desiredSizes, section);
|
|
171
|
-
const [leadingSpace] = getLeadingAndTrailingSpace(
|
|
172
|
-
|
|
173
|
-
section,
|
|
174
|
-
elements
|
|
175
|
-
);
|
|
176
|
-
const contentRect = AD.Rect.create(
|
|
177
|
-
rect.x,
|
|
178
|
-
rect.y - leadingSpace,
|
|
179
|
-
rect.width,
|
|
180
|
-
rect.height + leadingSpace
|
|
181
|
-
);
|
|
231
|
+
const [leadingSpace] = getLeadingAndTrailingSpace(resources, section, elements);
|
|
232
|
+
const contentRect = AD.Rect.create(rect.x, rect.y - leadingSpace, rect.width, rect.height + leadingSpace);
|
|
182
233
|
|
|
183
234
|
return {
|
|
184
235
|
pageNo: pageNo,
|
|
@@ -188,14 +239,11 @@ function createPage(
|
|
|
188
239
|
contentRect: contentRect,
|
|
189
240
|
elements: elements,
|
|
190
241
|
header: section.page.header,
|
|
191
|
-
footer: section.page.footer
|
|
242
|
+
footer: section.page.footer,
|
|
192
243
|
};
|
|
193
244
|
}
|
|
194
245
|
|
|
195
|
-
function getPageContentRect(
|
|
196
|
-
desiredSizes: Map<{}, AD.Size.Size>,
|
|
197
|
-
section: AD.Section.Section
|
|
198
|
-
): AD.Rect.Rect {
|
|
246
|
+
function getPageContentRect(desiredSizes: Map<{}, AD.Size.Size>, section: AD.Section.Section): AD.Rect.Rect {
|
|
199
247
|
const style = section.page.style;
|
|
200
248
|
const pageWidth = AD.PageStyle.getWidth(style);
|
|
201
249
|
const pageHeight = AD.PageStyle.getHeight(style);
|
|
@@ -218,14 +266,8 @@ function getPageContentRect(
|
|
|
218
266
|
|
|
219
267
|
const rectX = style.contentMargins.left;
|
|
220
268
|
const rectY = headerY + style.contentMargins.top;
|
|
221
|
-
const rectWidth =
|
|
222
|
-
|
|
223
|
-
const rectHeight =
|
|
224
|
-
pageHeight -
|
|
225
|
-
headerHeight -
|
|
226
|
-
footerHeight -
|
|
227
|
-
style.contentMargins.top -
|
|
228
|
-
style.contentMargins.bottom;
|
|
269
|
+
const rectWidth = pageWidth - (style.contentMargins.left + style.contentMargins.right);
|
|
270
|
+
const rectHeight = pageHeight - headerHeight - footerHeight - style.contentMargins.top - style.contentMargins.bottom;
|
|
229
271
|
|
|
230
272
|
return AD.Rect.create(rectX, rectY, rectWidth, rectHeight);
|
|
231
273
|
}
|
|
@@ -243,8 +285,7 @@ function getLeadingAndTrailingSpace(
|
|
|
243
285
|
|
|
244
286
|
const last = elements.length > 0 ? elements[elements.length - 1] : undefined;
|
|
245
287
|
const lastMargins = last && getSectionElementMargin(resources, last);
|
|
246
|
-
const trailingSpace =
|
|
247
|
-
lastMargins && noTopBottomMargin ? lastMargins.bottom : 0;
|
|
288
|
+
const trailingSpace = lastMargins && noTopBottomMargin ? lastMargins.bottom : 0;
|
|
248
289
|
|
|
249
290
|
return [leadingSpace, trailingSpace];
|
|
250
291
|
}
|
|
@@ -266,7 +307,7 @@ function getSectionElementMargin(
|
|
|
266
307
|
bottom: 0,
|
|
267
308
|
left: 0,
|
|
268
309
|
right: 0,
|
|
269
|
-
top: 0
|
|
310
|
+
top: 0,
|
|
270
311
|
};
|
|
271
312
|
}
|
|
272
313
|
}
|
|
@@ -290,23 +331,20 @@ function getGroupMargins(
|
|
|
290
331
|
group: AD.Group.Group
|
|
291
332
|
): AD.LayoutFoundation.LayoutFoundation {
|
|
292
333
|
const first = group.children.length > 0 ? group.children[0] : undefined;
|
|
293
|
-
const last =
|
|
294
|
-
group.children.length > 0
|
|
295
|
-
? group.children[group.children.length - 1]
|
|
296
|
-
: undefined;
|
|
334
|
+
const last = group.children.length > 0 ? group.children[group.children.length - 1] : undefined;
|
|
297
335
|
const firstMargin = first && getSectionElementMargin(resources, first);
|
|
298
336
|
const lastMargin = last && getSectionElementMargin(resources, last);
|
|
299
337
|
if (firstMargin && lastMargin) {
|
|
300
338
|
return {
|
|
301
339
|
...firstMargin,
|
|
302
|
-
bottom: lastMargin.bottom
|
|
340
|
+
bottom: lastMargin.bottom,
|
|
303
341
|
};
|
|
304
342
|
} else {
|
|
305
343
|
return {
|
|
306
344
|
bottom: 0,
|
|
307
345
|
left: 0,
|
|
308
346
|
right: 0,
|
|
309
|
-
top: 0
|
|
347
|
+
top: 0,
|
|
310
348
|
};
|
|
311
349
|
}
|
|
312
350
|
}
|
|
@@ -325,13 +363,71 @@ function getTableMargins(
|
|
|
325
363
|
return style.margins;
|
|
326
364
|
}
|
|
327
365
|
|
|
328
|
-
function getDesiredSize(
|
|
329
|
-
element: {},
|
|
330
|
-
desiredSizes: Map<{}, AD.Size.Size>
|
|
331
|
-
): AD.Size.Size {
|
|
366
|
+
function getDesiredSize(element: {}, desiredSizes: Map<{}, AD.Size.Size>): AD.Size.Size {
|
|
332
367
|
const size = desiredSizes.get(element);
|
|
333
368
|
if (size) {
|
|
334
369
|
return size;
|
|
335
370
|
}
|
|
336
371
|
throw new Error("Could not find size for element!");
|
|
337
372
|
}
|
|
373
|
+
|
|
374
|
+
function splitTableAt(
|
|
375
|
+
pdfKit: any,
|
|
376
|
+
document: AD.AbstractDoc.AbstractDoc,
|
|
377
|
+
resources: AD.Resources.Resources,
|
|
378
|
+
desiredSizes: Map<{}, AD.Size.Size>,
|
|
379
|
+
table: AD.Table.Table,
|
|
380
|
+
splitIndex: number
|
|
381
|
+
): [AD.Table.Table, AD.Table.Table] {
|
|
382
|
+
//Push row/cells to head table while splitting rowspan
|
|
383
|
+
const headRows: AD.TableRow.TableRow[] = [];
|
|
384
|
+
for (const [rowIndex, row] of table.children.slice(0, splitIndex).entries()) {
|
|
385
|
+
const newRow: AD.TableCell.TableCell[] = [];
|
|
386
|
+
for (const cell of row.children) {
|
|
387
|
+
//If this cell would span over the split index
|
|
388
|
+
if (rowIndex + (cell.rowSpan || 1) - 1 >= splitIndex) {
|
|
389
|
+
newRow.push({ ...cell, rowSpan: splitIndex - rowIndex });
|
|
390
|
+
} else {
|
|
391
|
+
newRow.push(cell);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
headRows.push({ ...row, children: newRow });
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
//Set dummy to false for all cells in the splitRow
|
|
398
|
+
//This causes them to be rendered like an empty cell
|
|
399
|
+
//while keeping the remaining rowspan which was calculated
|
|
400
|
+
//in the pre-process step
|
|
401
|
+
const splitRow = table.children[splitIndex];
|
|
402
|
+
const firstTailRow: AD.TableCell.TableCell[] = [];
|
|
403
|
+
for (const cell of splitRow.children) {
|
|
404
|
+
firstTailRow.push({ ...cell, dummy: false });
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// Push the rest of the rows to tail table
|
|
408
|
+
const tailRows: AD.TableRow.TableRow[] = [{ ...splitRow, children: firstTailRow }];
|
|
409
|
+
tailRows.push(...table.children.slice(splitIndex + 1));
|
|
410
|
+
|
|
411
|
+
//Create tables and remeasure them
|
|
412
|
+
const tableHead = {
|
|
413
|
+
...table,
|
|
414
|
+
style: { ...table.style, margins: { ...table.style.margins, bottom: 0 } },
|
|
415
|
+
children: headRows,
|
|
416
|
+
};
|
|
417
|
+
const tableTail = {
|
|
418
|
+
...table,
|
|
419
|
+
style: { ...table.style, margins: { ...table.style.margins, top: 0 } },
|
|
420
|
+
children: tailRows,
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
const availableSize = getDesiredSize(table, desiredSizes);
|
|
424
|
+
let pdf = new pdfKit();
|
|
425
|
+
registerFonts((fontName: string, fontSource: AD.Font.FontSource) => pdf.registerFont(fontName, fontSource), document);
|
|
426
|
+
const headSizes = measureTable(pdf, resources, availableSize, tableHead);
|
|
427
|
+
const tailSizes = measureTable(pdf, resources, availableSize, tableTail);
|
|
428
|
+
|
|
429
|
+
headSizes.forEach((value, key) => desiredSizes.set(key, value));
|
|
430
|
+
tailSizes.forEach((value, key) => desiredSizes.set(key, value));
|
|
431
|
+
|
|
432
|
+
return [tableHead, tableTail];
|
|
433
|
+
}
|
|
@@ -3,8 +3,6 @@ import * as AD from "../../abstract-document/index";
|
|
|
3
3
|
import { exhaustiveCheck } from "ts-exhaustive-check/lib-cjs";
|
|
4
4
|
import * as TextStyle from "../../abstract-document/styles/text-style";
|
|
5
5
|
|
|
6
|
-
type RowSpans = Map<number, { rowSpanLeft: number; colSpan: number }>;
|
|
7
|
-
|
|
8
6
|
const alphabet = [
|
|
9
7
|
"a",
|
|
10
8
|
"b",
|
|
@@ -285,8 +283,15 @@ function toChar(num: number): string {
|
|
|
285
283
|
// }
|
|
286
284
|
|
|
287
285
|
function preProcessTable(table: AD.Table.Table, resources: AD.Resources.Resources): AD.SectionElement.SectionElement {
|
|
286
|
+
const processedHeaders = [];
|
|
288
287
|
const processedChildren = [];
|
|
289
|
-
let rowSpans:
|
|
288
|
+
let rowSpans: Map<number, AD.TableCell.TableCell> = new Map();
|
|
289
|
+
if (table.headerRows) {
|
|
290
|
+
for (const row of table.headerRows) {
|
|
291
|
+
const header = preProcessTableRow(row, rowSpans, resources);
|
|
292
|
+
processedHeaders.push(header);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
290
295
|
for (const row of table.children) {
|
|
291
296
|
const children = preProcessTableRow(row, rowSpans, resources);
|
|
292
297
|
processedChildren.push(children);
|
|
@@ -296,6 +301,7 @@ function preProcessTable(table: AD.Table.Table, resources: AD.Resources.Resource
|
|
|
296
301
|
columnWidths: table.columnWidths,
|
|
297
302
|
styleName: table.styleName,
|
|
298
303
|
style: table.style,
|
|
304
|
+
headerRows: processedHeaders,
|
|
299
305
|
},
|
|
300
306
|
processedChildren
|
|
301
307
|
);
|
|
@@ -303,53 +309,43 @@ function preProcessTable(table: AD.Table.Table, resources: AD.Resources.Resource
|
|
|
303
309
|
|
|
304
310
|
function preProcessTableRow(
|
|
305
311
|
r: AD.TableRow.TableRow,
|
|
306
|
-
rowSpans:
|
|
312
|
+
rowSpans: Map<number, AD.TableCell.TableCell>,
|
|
307
313
|
resources: AD.Resources.Resources
|
|
308
314
|
): AD.TableRow.TableRow {
|
|
309
315
|
const processedChildren = [];
|
|
310
|
-
let
|
|
316
|
+
let columnIndex = 0;
|
|
311
317
|
for (const cell of r.children) {
|
|
312
|
-
let
|
|
313
|
-
while (
|
|
314
|
-
processedChildren.push(
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
})
|
|
320
|
-
);
|
|
321
|
-
rowSpan.rowSpanLeft -= 1;
|
|
322
|
-
if (rowSpan.rowSpanLeft < 1) {
|
|
323
|
-
rowSpans.delete(cellIndex);
|
|
318
|
+
let dummyCell = rowSpans.get(columnIndex);
|
|
319
|
+
while (dummyCell) {
|
|
320
|
+
processedChildren.push(dummyCell);
|
|
321
|
+
if (dummyCell.rowSpan <= 1) {
|
|
322
|
+
rowSpans.delete(columnIndex);
|
|
323
|
+
} else {
|
|
324
|
+
rowSpans.set(columnIndex, { ...dummyCell, rowSpan: dummyCell.rowSpan - 1 });
|
|
324
325
|
}
|
|
325
|
-
|
|
326
|
-
|
|
326
|
+
columnIndex += dummyCell.columnSpan || 1;
|
|
327
|
+
dummyCell = rowSpans.get(columnIndex);
|
|
327
328
|
}
|
|
328
329
|
|
|
329
330
|
const processedCell = preProcessTableCell(cell, resources);
|
|
330
331
|
processedChildren.push(processedCell);
|
|
331
332
|
if ((processedCell.rowSpan || 1) > 1) {
|
|
332
|
-
rowSpans.set(
|
|
333
|
+
rowSpans.set(columnIndex, { ...processedCell, children: [], rowSpan: processedCell.rowSpan - 1, dummy: true });
|
|
333
334
|
}
|
|
334
|
-
|
|
335
|
+
columnIndex += cell.columnSpan || 1;
|
|
335
336
|
}
|
|
336
337
|
|
|
337
338
|
// Make sure to reduce the rowSpanLeft of any cell that is at the end
|
|
338
|
-
let
|
|
339
|
-
while (
|
|
340
|
-
processedChildren.push(
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
})
|
|
346
|
-
);
|
|
347
|
-
rowSpan.rowSpanLeft -= 1;
|
|
348
|
-
if (rowSpan.rowSpanLeft < 1) {
|
|
349
|
-
rowSpans.delete(cellIndex);
|
|
339
|
+
let dummyCell = rowSpans.get(columnIndex);
|
|
340
|
+
while (dummyCell) {
|
|
341
|
+
processedChildren.push(dummyCell);
|
|
342
|
+
if (dummyCell.rowSpan <= 1) {
|
|
343
|
+
rowSpans.delete(columnIndex);
|
|
344
|
+
} else {
|
|
345
|
+
rowSpans.set(columnIndex, { ...dummyCell, rowSpan: dummyCell.rowSpan - 1 });
|
|
350
346
|
}
|
|
351
|
-
|
|
352
|
-
|
|
347
|
+
columnIndex += dummyCell.columnSpan || 1;
|
|
348
|
+
dummyCell = rowSpans.get(columnIndex);
|
|
353
349
|
}
|
|
354
350
|
|
|
355
351
|
return AD.TableRow.create({}, processedChildren);
|