abstract-document 20.0.4 → 20.1.1

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.
Files changed (214) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/lib/abstract-document/abstract-doc.d.ts.map +1 -1
  3. package/lib/abstract-document/abstract-doc.js +2 -2
  4. package/lib/abstract-document/atoms/atom.d.ts +3 -3
  5. package/lib/abstract-document/atoms/atom.d.ts.map +1 -1
  6. package/lib/abstract-document/default-styles.d.ts.map +1 -1
  7. package/lib/abstract-document/default-styles.js.map +1 -1
  8. package/lib/abstract-document/markdown/markdown.d.ts.map +1 -1
  9. package/lib/abstract-document/markdown/markdown.js +4 -4
  10. package/lib/abstract-document/markdown/markdown.js.map +1 -1
  11. package/lib/abstract-document/numberings/numbering-definition.d.ts +2 -2
  12. package/lib/abstract-document/numberings/numbering-definition.d.ts.map +1 -1
  13. package/lib/abstract-document/numberings/numbering-level-definition.js +2 -2
  14. package/lib/abstract-document/page/master-page.d.ts +1 -1
  15. package/lib/abstract-document/page/master-page.d.ts.map +1 -1
  16. package/lib/abstract-document/page/master-page.js +1 -1
  17. package/lib/abstract-document/page/master-page.js.map +1 -1
  18. package/lib/abstract-document/page/section.d.ts +1 -1
  19. package/lib/abstract-document/page/section.d.ts.map +1 -1
  20. package/lib/abstract-document/page/section.js +2 -2
  21. package/lib/abstract-document/page/section.js.map +1 -1
  22. package/lib/abstract-document/primitives/font.d.ts +1 -1
  23. package/lib/abstract-document/primitives/font.d.ts.map +1 -1
  24. package/lib/abstract-document/primitives/font.js +1 -1
  25. package/lib/abstract-document/primitives/font.js.map +1 -1
  26. package/lib/abstract-document/primitives/layout-foundation-color.d.ts.map +1 -1
  27. package/lib/abstract-document/primitives/layout-foundation-color.js.map +1 -1
  28. package/lib/abstract-document/primitives/layout-foundation.d.ts.map +1 -1
  29. package/lib/abstract-document/primitives/layout-foundation.js.map +1 -1
  30. package/lib/abstract-document/resources.d.ts +4 -3
  31. package/lib/abstract-document/resources.d.ts.map +1 -1
  32. package/lib/abstract-document/resources.js +4 -4
  33. package/lib/abstract-document/resources.js.map +1 -1
  34. package/lib/abstract-document/section-elements/group.d.ts +1 -1
  35. package/lib/abstract-document/section-elements/group.d.ts.map +1 -1
  36. package/lib/abstract-document/section-elements/group.js +2 -2
  37. package/lib/abstract-document/section-elements/group.js.map +1 -1
  38. package/lib/abstract-document/section-elements/page-break.d.ts +2 -2
  39. package/lib/abstract-document/section-elements/page-break.d.ts.map +1 -1
  40. package/lib/abstract-document/section-elements/page-break.js +1 -2
  41. package/lib/abstract-document/section-elements/page-break.js.map +1 -1
  42. package/lib/abstract-document/section-elements/paragraph.d.ts +2 -2
  43. package/lib/abstract-document/section-elements/paragraph.d.ts.map +1 -1
  44. package/lib/abstract-document/section-elements/paragraph.js +2 -2
  45. package/lib/abstract-document/section-elements/paragraph.js.map +1 -1
  46. package/lib/abstract-document/section-elements/section-element.d.ts +1 -1
  47. package/lib/abstract-document/section-elements/section-element.d.ts.map +1 -1
  48. package/lib/abstract-document/section-elements/section-element.js.map +1 -1
  49. package/lib/abstract-document/section-elements/table.d.ts +1 -1
  50. package/lib/abstract-document/section-elements/table.d.ts.map +1 -1
  51. package/lib/abstract-document/section-elements/table.js +2 -2
  52. package/lib/abstract-document/section-elements/table.js.map +1 -1
  53. package/lib/abstract-document/styles/group-style.js +3 -3
  54. package/lib/abstract-document/styles/page-style.d.ts.map +1 -1
  55. package/lib/abstract-document/styles/page-style.js +3 -7
  56. package/lib/abstract-document/styles/page-style.js.map +1 -1
  57. package/lib/abstract-document/styles/paragraph-style.d.ts +1 -1
  58. package/lib/abstract-document/styles/paragraph-style.d.ts.map +1 -1
  59. package/lib/abstract-document/styles/paragraph-style.js +5 -5
  60. package/lib/abstract-document/styles/paragraph-style.js.map +1 -1
  61. package/lib/abstract-document/styles/style.d.ts.map +1 -1
  62. package/lib/abstract-document/styles/style.js.map +1 -1
  63. package/lib/abstract-document/styles/table-cell-style.d.ts +1 -1
  64. package/lib/abstract-document/styles/table-cell-style.d.ts.map +1 -1
  65. package/lib/abstract-document/styles/table-cell-style.js +7 -7
  66. package/lib/abstract-document/styles/table-cell-style.js.map +1 -1
  67. package/lib/abstract-document/styles/table-style.d.ts +1 -1
  68. package/lib/abstract-document/styles/table-style.d.ts.map +1 -1
  69. package/lib/abstract-document/styles/table-style.js +2 -2
  70. package/lib/abstract-document/styles/table-style.js.map +1 -1
  71. package/lib/abstract-document/styles/text-style.d.ts.map +1 -1
  72. package/lib/abstract-document/styles/text-style.js +16 -21
  73. package/lib/abstract-document/styles/text-style.js.map +1 -1
  74. package/lib/abstract-document/table/table-cell.js +2 -2
  75. package/lib/abstract-document/table/table-row.d.ts +2 -3
  76. package/lib/abstract-document/table/table-row.d.ts.map +1 -1
  77. package/lib/abstract-document/table/table-row.js +2 -3
  78. package/lib/abstract-document/table/table-row.js.map +1 -1
  79. package/lib/abstract-document/types.d.ts.map +1 -1
  80. package/lib/abstract-document-exporters/docx/document-container.d.ts +5 -5
  81. package/lib/abstract-document-exporters/docx/document-container.d.ts.map +1 -1
  82. package/lib/abstract-document-exporters/docx/document-container.js +14 -13
  83. package/lib/abstract-document-exporters/docx/document-container.js.map +1 -1
  84. package/lib/abstract-document-exporters/docx/docx-constants.d.ts.map +1 -1
  85. package/lib/abstract-document-exporters/docx/docx-constants.js +1 -4
  86. package/lib/abstract-document-exporters/docx/docx-constants.js.map +1 -1
  87. package/lib/abstract-document-exporters/docx/ref-container.d.ts +8 -10
  88. package/lib/abstract-document-exporters/docx/ref-container.d.ts.map +1 -1
  89. package/lib/abstract-document-exporters/docx/ref-container.js +34 -35
  90. package/lib/abstract-document-exporters/docx/ref-container.js.map +1 -1
  91. package/lib/abstract-document-exporters/docx/string-utils.d.ts +2 -1
  92. package/lib/abstract-document-exporters/docx/string-utils.d.ts.map +1 -1
  93. package/lib/abstract-document-exporters/docx/string-utils.js +6 -4
  94. package/lib/abstract-document-exporters/docx/string-utils.js.map +1 -1
  95. package/lib/abstract-document-exporters/docx/xml-writer.d.ts +12 -33
  96. package/lib/abstract-document-exporters/docx/xml-writer.d.ts.map +1 -1
  97. package/lib/abstract-document-exporters/docx/xml-writer.js +243 -249
  98. package/lib/abstract-document-exporters/docx/xml-writer.js.map +1 -1
  99. package/lib/abstract-document-exporters/docx2/render-image.d.ts +1 -1
  100. package/lib/abstract-document-exporters/docx2/render-image.d.ts.map +1 -1
  101. package/lib/abstract-document-exporters/docx2/render-image.js +4 -16
  102. package/lib/abstract-document-exporters/docx2/render-image.js.map +1 -1
  103. package/lib/abstract-document-exporters/docx2/render.d.ts.map +1 -1
  104. package/lib/abstract-document-exporters/docx2/render.js +28 -38
  105. package/lib/abstract-document-exporters/docx2/render.js.map +1 -1
  106. package/lib/abstract-document-exporters/pdf/font.d.ts.map +1 -1
  107. package/lib/abstract-document-exporters/pdf/font.js +13 -14
  108. package/lib/abstract-document-exporters/pdf/font.js.map +1 -1
  109. package/lib/abstract-document-exporters/pdf/header-footer.d.ts +8 -0
  110. package/lib/abstract-document-exporters/pdf/header-footer.d.ts.map +1 -0
  111. package/lib/abstract-document-exporters/pdf/header-footer.js +31 -0
  112. package/lib/abstract-document-exporters/pdf/header-footer.js.map +1 -0
  113. package/lib/abstract-document-exporters/pdf/measure.d.ts +4 -4
  114. package/lib/abstract-document-exporters/pdf/measure.d.ts.map +1 -1
  115. package/lib/abstract-document-exporters/pdf/measure.js +29 -31
  116. package/lib/abstract-document-exporters/pdf/measure.js.map +1 -1
  117. package/lib/abstract-document-exporters/pdf/page.d.ts +15 -0
  118. package/lib/abstract-document-exporters/pdf/page.d.ts.map +1 -0
  119. package/lib/abstract-document-exporters/pdf/page.js +2 -0
  120. package/lib/abstract-document-exporters/pdf/page.js.map +1 -0
  121. package/lib/abstract-document-exporters/pdf/paginate.d.ts +2 -20
  122. package/lib/abstract-document-exporters/pdf/paginate.d.ts.map +1 -1
  123. package/lib/abstract-document-exporters/pdf/paginate.js +8 -45
  124. package/lib/abstract-document-exporters/pdf/paginate.js.map +1 -1
  125. package/lib/abstract-document-exporters/pdf/pre-process.d.ts.map +1 -1
  126. package/lib/abstract-document-exporters/pdf/pre-process.js +8 -35
  127. package/lib/abstract-document-exporters/pdf/pre-process.js.map +1 -1
  128. package/lib/abstract-document-exporters/pdf/render-image.d.ts.map +1 -1
  129. package/lib/abstract-document-exporters/pdf/render-image.js +24 -34
  130. package/lib/abstract-document-exporters/pdf/render-image.js.map +1 -1
  131. package/lib/abstract-document-exporters/pdf/render.d.ts +4 -3
  132. package/lib/abstract-document-exporters/pdf/render.d.ts.map +1 -1
  133. package/lib/abstract-document-exporters/pdf/render.js +60 -50
  134. package/lib/abstract-document-exporters/pdf/render.js.map +1 -1
  135. package/lib/abstract-document-exporters/pdf/std-fonts.js +1 -1
  136. package/lib/abstract-document-exporters/pdf/std-fonts.js.map +1 -1
  137. package/lib/abstract-document-exporters/pdf/textRunRow.d.ts +3 -3
  138. package/lib/abstract-document-exporters/pdf/textRunRow.d.ts.map +1 -1
  139. package/lib/abstract-document-exporters/pdf/textRunRow.js +6 -6
  140. package/lib/abstract-document-exporters/pdf/textRunRow.js.map +1 -1
  141. package/lib/abstract-document-exporters/pdf/update-refs.d.ts +1 -1
  142. package/lib/abstract-document-exporters/pdf/update-refs.d.ts.map +1 -1
  143. package/lib/abstract-document-exporters/pdf/update-refs.js +3 -2
  144. package/lib/abstract-document-exporters/pdf/update-refs.js.map +1 -1
  145. package/lib/abstract-document-exporters/shared/get_resources.d.ts.map +1 -1
  146. package/lib/abstract-document-exporters/shared/get_resources.js.map +1 -1
  147. package/lib/abstract-document-jsx/index.d.ts +2 -3
  148. package/lib/abstract-document-jsx/index.d.ts.map +1 -1
  149. package/lib/abstract-document-jsx/index.js +10 -6
  150. package/lib/abstract-document-jsx/index.js.map +1 -1
  151. package/lib/abstract-document-xml/abstract-doc-of-xml/abstract-doc-of-xml.d.ts +3 -7
  152. package/lib/abstract-document-xml/abstract-doc-of-xml/abstract-doc-of-xml.d.ts.map +1 -1
  153. package/lib/abstract-document-xml/abstract-doc-of-xml/abstract-doc-of-xml.js +5 -3
  154. package/lib/abstract-document-xml/abstract-doc-of-xml/abstract-doc-of-xml.js.map +1 -1
  155. package/lib/abstract-document-xml/abstract-doc-of-xml/creator.d.ts.map +1 -1
  156. package/lib/abstract-document-xml/abstract-doc-of-xml/creator.js +1 -3
  157. package/lib/abstract-document-xml/abstract-doc-of-xml/creator.js.map +1 -1
  158. package/lib/abstract-document-xml/abstract-doc-of-xml/custom-elements.d.ts.map +1 -1
  159. package/lib/abstract-document-xml/abstract-doc-of-xml/custom-elements.js +4 -8
  160. package/lib/abstract-document-xml/abstract-doc-of-xml/custom-elements.js.map +1 -1
  161. package/lib/abstract-document-xml/xsd-template/xsd-template.js +2 -2
  162. package/lib/abstract-document-xml/xsd-template/xsd-template.js.map +1 -1
  163. package/package.json +22 -22
  164. package/src/abstract-document/abstract-doc.ts +6 -6
  165. package/src/abstract-document/atoms/atom.ts +3 -3
  166. package/src/abstract-document/default-styles.ts +1 -1
  167. package/src/abstract-document/markdown/markdown.ts +5 -5
  168. package/src/abstract-document/numberings/numbering-definition.ts +2 -2
  169. package/src/abstract-document/numberings/numbering-level-definition.ts +2 -2
  170. package/src/abstract-document/page/master-page.ts +2 -2
  171. package/src/abstract-document/page/section.ts +3 -3
  172. package/src/abstract-document/primitives/font.ts +1 -12
  173. package/src/abstract-document/primitives/layout-foundation-color.ts +1 -4
  174. package/src/abstract-document/primitives/layout-foundation.ts +1 -4
  175. package/src/abstract-document/resources.ts +9 -14
  176. package/src/abstract-document/section-elements/group.ts +3 -3
  177. package/src/abstract-document/section-elements/page-break.ts +2 -3
  178. package/src/abstract-document/section-elements/paragraph.ts +4 -4
  179. package/src/abstract-document/section-elements/section-element.ts +1 -1
  180. package/src/abstract-document/section-elements/table.ts +3 -3
  181. package/src/abstract-document/styles/group-style.ts +3 -3
  182. package/src/abstract-document/styles/page-style.ts +3 -7
  183. package/src/abstract-document/styles/paragraph-style.ts +6 -14
  184. package/src/abstract-document/styles/style.ts +1 -5
  185. package/src/abstract-document/styles/table-cell-style.ts +8 -11
  186. package/src/abstract-document/styles/table-style.ts +3 -8
  187. package/src/abstract-document/styles/text-style.ts +16 -21
  188. package/src/abstract-document/table/table-cell.ts +2 -2
  189. package/src/abstract-document/table/table-row.ts +3 -4
  190. package/src/abstract-document/types.ts +0 -1
  191. package/src/abstract-document-exporters/docx/document-container.ts +24 -13
  192. package/src/abstract-document-exporters/docx/docx-constants.ts +2 -6
  193. package/src/abstract-document-exporters/docx/ref-container.ts +48 -41
  194. package/src/abstract-document-exporters/docx/string-utils.ts +6 -6
  195. package/src/abstract-document-exporters/docx/xml-writer.ts +261 -266
  196. package/src/abstract-document-exporters/docx2/render-image.ts +15 -49
  197. package/src/abstract-document-exporters/docx2/render.ts +64 -139
  198. package/src/abstract-document-exporters/pdf/font.ts +17 -23
  199. package/src/abstract-document-exporters/pdf/header-footer.ts +43 -0
  200. package/src/abstract-document-exporters/pdf/measure.ts +50 -103
  201. package/src/abstract-document-exporters/pdf/page.ts +16 -0
  202. package/src/abstract-document-exporters/pdf/paginate.ts +29 -125
  203. package/src/abstract-document-exporters/pdf/pre-process.ts +11 -47
  204. package/src/abstract-document-exporters/pdf/render-image.ts +29 -46
  205. package/src/abstract-document-exporters/pdf/render.ts +84 -129
  206. package/src/abstract-document-exporters/pdf/std-fonts.ts +1 -1
  207. package/src/abstract-document-exporters/pdf/textRunRow.ts +12 -23
  208. package/src/abstract-document-exporters/pdf/update-refs.ts +10 -33
  209. package/src/abstract-document-exporters/shared/get_resources.ts +4 -4
  210. package/src/abstract-document-jsx/index.ts +38 -26
  211. package/src/abstract-document-xml/abstract-doc-of-xml/abstract-doc-of-xml.ts +14 -26
  212. package/src/abstract-document-xml/abstract-doc-of-xml/creator.ts +10 -28
  213. package/src/abstract-document-xml/abstract-doc-of-xml/custom-elements.tsx +8 -30
  214. package/src/abstract-document-xml/xsd-template/xsd-template.ts +2 -2
@@ -1,10 +1,10 @@
1
1
  import type * as AbstractImage from "abstract-image";
2
2
  import type { IMediaTransformation } from "docx";
3
3
  import { ImageRun } from "docx";
4
- import type { TextStyle } from "../../abstract-document/styles/text-style.js";
5
4
  import type { Image } from "../../abstract-document/atoms/image.js";
6
- import { fromBase64, rawSvgPrefix } from "../shared/base-64.js";
7
5
  import type * as AD from "../../abstract-document/index.js";
6
+ import type { TextStyle } from "../../abstract-document/styles/text-style.js";
7
+ import { fromBase64, rawSvgPrefix } from "../shared/base-64.js";
8
8
 
9
9
  const abstractDocPointsToDocxPxRatio = 1; // Set to 1 for now to minimize impact. Can be adjusted to better match PDF image dimensions
10
10
 
@@ -87,13 +87,9 @@ function binaryImageToImageRun(
87
87
  if (format === "png" || format === "jpg" || format === "jpeg") {
88
88
  return new ImageRun({
89
89
  type: format === "png" ? "png" : "jpg",
90
- data: Buffer.from(
91
- component.data.bytes.buffer,
92
- component.data.bytes.byteOffset,
93
- component.data.bytes.byteLength
94
- ),
90
+ data: Buffer.from(component.data.bytes.buffer, component.data.bytes.byteOffset, component.data.bytes.byteLength),
95
91
  transformation,
96
- } as any);
92
+ });
97
93
  }
98
94
 
99
95
  if (format === "svg") {
@@ -131,11 +127,11 @@ function binaryImageToImageRun(
131
127
  const data = fromBase64(match[2]);
132
128
 
133
129
  if (mimeType.includes("png")) {
134
- return new ImageRun({ data, transformation, type: "png" } as any);
130
+ return new ImageRun({ data, transformation, type: "png" });
135
131
  }
136
132
 
137
133
  if (mimeType.includes("jpeg") || mimeType.includes("jpg")) {
138
- return new ImageRun({ data, transformation, type: "jpg" } as any);
134
+ return new ImageRun({ data, transformation, type: "jpg" });
139
135
  }
140
136
 
141
137
  if (mimeType.includes("svg")) {
@@ -147,11 +143,7 @@ function binaryImageToImageRun(
147
143
  return undefined;
148
144
  }
149
145
 
150
- function abstractImageToSvg(
151
- image: AbstractImage.AbstractImage,
152
- resources: AD.Resources.Resources,
153
- textStyle: TextStyle
154
- ): string {
146
+ function abstractImageToSvg(image: AbstractImage.AbstractImage, resources: AD.Resources.Resources, textStyle: TextStyle): string {
155
147
  const width = image.size.width || 1;
156
148
  const height = image.size.height || 1;
157
149
 
@@ -163,12 +155,7 @@ function abstractImageToSvg(
163
155
  return `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}">${children}</svg>`;
164
156
  }
165
157
 
166
- function componentToSvg(
167
- component: AbstractImage.Component,
168
- resources: AD.Resources.Resources,
169
- textStyle: TextStyle,
170
- circuitBreaker: number
171
- ): string {
158
+ function componentToSvg(component: AbstractImage.Component, resources: AD.Resources.Resources, textStyle: TextStyle, circuitBreaker: number): string {
172
159
  if (++circuitBreaker > 20) {
173
160
  return "";
174
161
  }
@@ -182,9 +169,7 @@ function componentToSvg(
182
169
  const scaleY = component.size.height / (component.image.size.height || 1);
183
170
  const scale = Math.min(scaleX, scaleY);
184
171
 
185
- const children = component.image.components
186
- .map((child) => componentToSvg(child, resources, textStyle, circuitBreaker))
187
- .join("");
172
+ const children = component.image.components.map((child) => componentToSvg(child, resources, textStyle, circuitBreaker)).join("");
188
173
 
189
174
  return `<g transform="translate(${component.topLeft.x} ${component.topLeft.y}) scale(${scale})">${children}</g>`;
190
175
  }
@@ -259,9 +244,7 @@ function binaryImageToSvg(
259
244
  const scaleY = height / (imageResource.abstractImage.size.height || 1);
260
245
  const scale = Math.min(scaleX, scaleY);
261
246
 
262
- const children = imageResource.abstractImage.components
263
- .map((child) => componentToSvg(child, resources, textStyle, circuitBreaker))
264
- .join("");
247
+ const children = imageResource.abstractImage.components.map((child) => componentToSvg(child, resources, textStyle, circuitBreaker)).join("");
265
248
 
266
249
  return `<g transform="translate(${component.topLeft.x} ${component.topLeft.y}) scale(${scale})">${children}</g>`;
267
250
  }
@@ -279,11 +262,7 @@ function binaryImageToSvg(
279
262
  if (component.data.type === "bytes") {
280
263
  if (format === "png" || format === "jpg" || format === "jpeg") {
281
264
  const mime = format === "png" ? "image/png" : "image/jpeg";
282
- const base64 = Buffer.from(
283
- component.data.bytes.buffer,
284
- component.data.bytes.byteOffset,
285
- component.data.bytes.byteLength
286
- ).toString("base64");
265
+ const base64 = Buffer.from(component.data.bytes.buffer, component.data.bytes.byteOffset, component.data.bytes.byteLength).toString("base64");
287
266
 
288
267
  return `<image x="${component.topLeft.x}" y="${component.topLeft.y}" width="${width}" height="${height}" href="data:${mime};base64,${base64}" />`;
289
268
  }
@@ -303,19 +282,10 @@ function textComponentToSvg(component: AbstractImage.Text): string {
303
282
  ? ` transform="rotate(${component.clockwiseRotationDegrees} ${component.position.x} ${component.position.y})"`
304
283
  : "";
305
284
 
306
- const anchor =
307
- component.horizontalGrowthDirection === "left"
308
- ? "end"
309
- : component.horizontalGrowthDirection === "uniform"
310
- ? "middle"
311
- : "start";
285
+ const anchor = component.horizontalGrowthDirection === "left" ? "end" : component.horizontalGrowthDirection === "uniform" ? "middle" : "start";
312
286
 
313
287
  const dominantBaseline =
314
- component.verticalGrowthDirection === "up"
315
- ? "text-after-edge"
316
- : component.verticalGrowthDirection === "uniform"
317
- ? "middle"
318
- : "text-before-edge";
288
+ component.verticalGrowthDirection === "up" ? "text-after-edge" : component.verticalGrowthDirection === "uniform" ? "middle" : "text-before-edge";
319
289
 
320
290
  return `<text x="${component.position.x}" y="${component.position.y}" font-family="${escapeXml(
321
291
  component.fontFamily
@@ -333,14 +303,10 @@ function fillAttrs(color: AbstractImage.Color): string {
333
303
  function strokeAttrs(color: AbstractImage.Color, thickness: number, dashStyle: AbstractImage.DashStyle): string {
334
304
  const dashArray =
335
305
  dashStyle.dashes.length > 0
336
- ? ` stroke-dasharray="${dashStyle.dashes.filter((dash) => dash !== 0).join(" ")}" stroke-dashoffset="${
337
- dashStyle.offset
338
- }"`
306
+ ? ` stroke-dasharray="${dashStyle.dashes.filter((dash) => dash !== 0).join(" ")}" stroke-dashoffset="${dashStyle.offset}"`
339
307
  : "";
340
308
 
341
- return `stroke="${colorToCss(color)}" stroke-opacity="${colorToOpacity(
342
- color
343
- )}" stroke-width="${thickness}"${dashArray}`;
309
+ return `stroke="${colorToCss(color)}" stroke-opacity="${colorToOpacity(color)}" stroke-width="${thickness}"${dashArray}`;
344
310
  }
345
311
 
346
312
  function colorToOpacity(color: AbstractImage.Color): number {
@@ -1,4 +1,4 @@
1
- import * as AD from "../../abstract-document/index.js";
1
+ import { Readable } from "stream";
2
2
  import type {
3
3
  ISectionOptions,
4
4
  ImageRun,
@@ -31,8 +31,8 @@ import {
31
31
  VerticalAlign,
32
32
  PageNumber,
33
33
  } from "docx";
34
+ import * as AD from "../../abstract-document/index.js";
34
35
  import { renderImage } from "./render-image.js";
35
- import { Readable } from "stream";
36
36
 
37
37
  const abstractDocToDocxFontRatio = 2;
38
38
  const abstractDocPixelToDocxDXARatio = 20;
@@ -63,8 +63,9 @@ export function exportToStream(blobStream: NodeJS.WritableStream, doc: AD.Abstra
63
63
  }
64
64
 
65
65
  /**
66
- * On the client side the stream can be a BlobStream from the blob-stream package.
67
- * On the server-side the stream can be a file stream from the fs package.
66
+ * On the client side the stream can be a BlobStream from the blob-stream package. On the server-side the stream can be a file stream from the fs
67
+ * package.
68
+ *
68
69
  * @param blobStream
69
70
  * @param doc
70
71
  */
@@ -89,40 +90,28 @@ function renderSection(section: AD.Section.Section, parentResources: AD.Resource
89
90
 
90
91
  const resources = AD.Resources.mergeResources([parentResources, section]);
91
92
 
92
- const headerChildren = section.page.header.reduce(
93
- (sofar, c) => {
94
- sofar.push(...renderSectionElement(c, resources, contentAvailableWidth));
95
- return sofar;
96
- },
97
- [] as Array<Paragraph | Table>
98
- );
93
+ const headerChildren = section.page.header.reduce<Array<Paragraph | Table>>((sofar, c) => {
94
+ sofar.push(...renderSectionElement(c, resources, contentAvailableWidth));
95
+ return sofar;
96
+ }, []);
99
97
 
100
98
  const firstpageHeaderChildren = hasFrontHeader
101
- ? section.page.frontHeader.reduce(
102
- (sofar, c) => {
103
- sofar.push(...renderSectionElement(c, resources, contentAvailableWidth));
104
- return sofar;
105
- },
106
- [] as Array<Paragraph | Table>
107
- )
99
+ ? section.page.frontHeader.reduce<Array<Paragraph | Table>>((sofar, c) => {
100
+ sofar.push(...renderSectionElement(c, resources, contentAvailableWidth));
101
+ return sofar;
102
+ }, [])
108
103
  : [];
109
104
 
110
- const footerChildren = section.page.footer.reduce(
111
- (sofar, c) => {
112
- sofar.push(...renderSectionElement(c, resources, contentAvailableWidth));
113
- return sofar;
114
- },
115
- [] as Array<Paragraph | Table>
116
- );
105
+ const footerChildren = section.page.footer.reduce<Array<Paragraph | Table>>((sofar, c) => {
106
+ sofar.push(...renderSectionElement(c, resources, contentAvailableWidth));
107
+ return sofar;
108
+ }, []);
117
109
 
118
110
  const firstPageFooterChildren = hasFrontFooter
119
- ? section.page.frontFooter.reduce(
120
- (sofar, c) => {
121
- sofar.push(...renderSectionElement(c, resources, contentAvailableWidth));
122
- return sofar;
123
- },
124
- [] as Array<Paragraph | Table>
125
- )
111
+ ? section.page.frontFooter.reduce<Array<Paragraph | Table>>((sofar, c) => {
112
+ sofar.push(...renderSectionElement(c, resources, contentAvailableWidth));
113
+ return sofar;
114
+ }, [])
126
115
  : [];
127
116
 
128
117
  const contentChildren = [
@@ -135,13 +124,10 @@ function renderSection(section: AD.Section.Section, parentResources: AD.Resource
135
124
  }),
136
125
  ],
137
126
  }),
138
- ...section.children.reduce(
139
- (sofar, c) => {
140
- sofar.push(...renderSectionElement(c, resources, contentAvailableWidth));
141
- return sofar;
142
- },
143
- [] as Array<Paragraph | Table>
144
- ),
127
+ ...section.children.reduce<Array<Paragraph | Table>>((sofar, c) => {
128
+ sofar.push(...renderSectionElement(c, resources, contentAvailableWidth));
129
+ return sofar;
130
+ }, []),
145
131
  ];
146
132
 
147
133
  return {
@@ -152,8 +138,7 @@ function renderSection(section: AD.Section.Section, parentResources: AD.Resource
152
138
  //DOC JS does the orientation after the width and height are set
153
139
  width: AD.PageStyle.getPaperWidth(section.page.style.paperSize) * abstractDocPixelToDocxDXARatio,
154
140
  height: AD.PageStyle.getPaperHeight(section.page.style.paperSize) * abstractDocPixelToDocxDXARatio,
155
- orientation:
156
- section.page.style.orientation === "Landscape" ? PageOrientation.LANDSCAPE : PageOrientation.PORTRAIT,
141
+ orientation: section.page.style.orientation === "Landscape" ? PageOrientation.LANDSCAPE : PageOrientation.PORTRAIT,
157
142
  },
158
143
  margin: {
159
144
  bottom: pageContentMargins.bottom * abstractDocPixelToDocxDXARatio,
@@ -189,21 +174,18 @@ function renderSection(section: AD.Section.Section, parentResources: AD.Resource
189
174
  };
190
175
  }
191
176
 
192
- function renderHyperLink(
193
- hyperLink: AD.HyperLink.HyperLink,
194
- style: AD.TextStyle.TextStyle
195
- ): InternalHyperlink | ExternalHyperlink {
177
+ function renderHyperLink(hyperLink: AD.HyperLink.HyperLink, style: AD.TextStyle.TextStyle): InternalHyperlink | ExternalHyperlink {
196
178
  const fontSize = AD.TextStyle.calculateFontSize(style, 10) * 2;
197
179
  const textRun = new TextRun({
198
180
  text: hyperLink.text,
199
- font: style.fontFamily || "Helvetica",
181
+ font: style.fontFamily ?? "Helvetica",
200
182
  size: fontSize,
201
- color: style.color || "#0000ff",
202
- bold: style.bold || style.fontWeight === "bold",
183
+ color: style.color ?? "#0000ff",
184
+ bold: style.bold ?? style.fontWeight === "bold",
203
185
  characterSpacing: style.characterSpacing,
204
186
  underline: style.underline
205
187
  ? {
206
- color: style.color || "#0000ff",
188
+ color: style.color ?? "#0000ff",
207
189
  type: UnderlineType.SINGLE,
208
190
  }
209
191
  : undefined,
@@ -234,11 +216,10 @@ function renderSectionElement(
234
216
  return [renderParagraph(element, resources, keepNext)];
235
217
  case "Group":
236
218
  return [...renderGroup(element, parentResources, contentAvailableWidth)];
237
- case "Table":
219
+ case "Table": {
238
220
  const table = renderTable(element, resources, contentAvailableWidth, keepNext);
239
- return table
240
- ? [table, new Paragraph({ keepNext: keepNext, children: [new TextRun({ text: ".", size: 0.000001 })] })]
241
- : [];
221
+ return table ? [table, new Paragraph({ keepNext: keepNext, children: [new TextRun({ text: ".", size: 0.000001 })] })] : [];
222
+ }
242
223
  case "PageBreak":
243
224
  return [
244
225
  new Paragraph({
@@ -250,29 +231,15 @@ function renderSectionElement(
250
231
  }
251
232
  }
252
233
 
253
- function renderTable(
254
- table: AD.Table.Table,
255
- resources: AD.Resources.Resources,
256
- contentAvailableWidth: number,
257
- keepNext: boolean
258
- ): Table | undefined {
259
- const style = AD.Resources.getStyle(
260
- undefined,
261
- table.style,
262
- "TableStyle",
263
- table.styleName,
264
- resources
265
- ) as AD.TableStyle.TableStyle;
234
+ function renderTable(table: AD.Table.Table, resources: AD.Resources.Resources, contentAvailableWidth: number, keepNext: boolean): Table | undefined {
235
+ const style = AD.Resources.getStyle(undefined, table.style, "TableStyle", table.styleName, resources) as AD.TableStyle.TableStyle;
266
236
  const styleMargins = AD.LayoutFoundation.orDefault(style.margins);
267
237
 
268
238
  if (table.children.length === 0) {
269
239
  return undefined;
270
240
  }
271
241
 
272
- const tableWidthWithoutInfinity = table.columnWidths.reduce(
273
- (sofar, c) => (Number.isFinite(c) ? sofar + c : sofar),
274
- 0
275
- );
242
+ const tableWidthWithoutInfinity = table.columnWidths.reduce((sofar, c) => (Number.isFinite(c) ? sofar + c : sofar), 0);
276
243
  const amountOfInfinity = table.columnWidths.reduce((sofar, c) => (!Number.isFinite(c) ? sofar + 1 : sofar), 0);
277
244
  const infinityCellWidth = (contentAvailableWidth - tableWidthWithoutInfinity) / amountOfInfinity;
278
245
  const columnWidths = table.columnWidths.map((w) =>
@@ -281,12 +248,7 @@ function renderTable(
281
248
 
282
249
  return new Table({
283
250
  layout: "fixed",
284
- alignment:
285
- style.alignment === "Left"
286
- ? AlignmentType.LEFT
287
- : style.alignment === "Right"
288
- ? AlignmentType.RIGHT
289
- : AlignmentType.CENTER,
251
+ alignment: style.alignment === "Left" ? AlignmentType.LEFT : style.alignment === "Right" ? AlignmentType.RIGHT : AlignmentType.CENTER,
290
252
  margins: {
291
253
  top: styleMargins.top * abstractDocPixelToDocxDXARatio,
292
254
  bottom: styleMargins.bottom * abstractDocPixelToDocxDXARatio,
@@ -329,9 +291,7 @@ function renderTable(
329
291
  style: BorderStyle.NONE,
330
292
  },
331
293
  },
332
- rows: table.headerRows
333
- .concat(table.children)
334
- .map((c) => renderRow(c, resources, style.cellStyle, columnWidths, keepNext)),
294
+ rows: table.headerRows.concat(table.children).map((c) => renderRow(c, resources, style.cellStyle, columnWidths, keepNext)),
335
295
  });
336
296
  }
337
297
 
@@ -353,7 +313,7 @@ function renderRow(
353
313
  children: [...acc.children, renderCell(cell, resources, tableCellStyle, width, keepNext)],
354
314
  };
355
315
  },
356
- { columnIndex: 0, children: [] as TableCell[] }
316
+ { columnIndex: 0, children: [] as Array<TableCell> }
357
317
  ).children;
358
318
 
359
319
  return new TableRow({
@@ -371,13 +331,7 @@ function renderCell(
371
331
  ): TableCell {
372
332
  const abstractDocPxCellWidth = width / abstractDocPixelToDocxDXARatio;
373
333
 
374
- const style = AD.Resources.getStyle(
375
- tableCellStyle,
376
- cell.style,
377
- "TableCellStyle",
378
- cell.styleName,
379
- resources
380
- ) as AD.TableCellStyle.TableCellStyle;
334
+ const style = AD.Resources.getStyle(tableCellStyle, cell.style, "TableCellStyle", cell.styleName, resources) as AD.TableCellStyle.TableCellStyle;
381
335
 
382
336
  const stylePadding = AD.LayoutFoundation.orDefault(style.padding);
383
337
  const styleBorders = AD.LayoutFoundation.orDefault(style.borders);
@@ -390,7 +344,7 @@ function renderCell(
390
344
  ? VerticalAlign.BOTTOM
391
345
  : VerticalAlign.CENTER) || undefined,
392
346
  shading: {
393
- fill: style.background ? style.background : undefined,
347
+ fill: style.background ?? undefined,
394
348
  },
395
349
  columnSpan: cell.columnSpan,
396
350
  rowSpan: cell.rowSpan,
@@ -427,13 +381,10 @@ function renderCell(
427
381
  },
428
382
  },
429
383
 
430
- children: cell.children.reduce(
431
- (sofar, c) => {
432
- sofar.push(...renderSectionElement(c, resources, abstractDocPxCellWidth, keepNext));
433
- return sofar;
434
- },
435
- [] as Array<Paragraph | Table>
436
- ),
384
+ children: cell.children.reduce<Array<Paragraph | Table>>((sofar, c) => {
385
+ sofar.push(...renderSectionElement(c, resources, abstractDocPxCellWidth, keepNext));
386
+ return sofar;
387
+ }, []),
437
388
  });
438
389
  }
439
390
 
@@ -470,18 +421,8 @@ function renderAtom(
470
421
  }
471
422
  }
472
423
 
473
- function renderTextField(
474
- resources: AD.Resources.Resources,
475
- textStyle: AD.TextStyle.TextStyle,
476
- textField: AD.TextField.TextField
477
- ): TextRun {
478
- const style = AD.Resources.getStyle(
479
- textStyle,
480
- textField.style,
481
- "TextStyle",
482
- textField.styleName,
483
- resources
484
- ) as AD.TextStyle.TextStyle;
424
+ function renderTextField(resources: AD.Resources.Resources, textStyle: AD.TextStyle.TextStyle, textField: AD.TextField.TextField): TextRun {
425
+ const style = AD.Resources.getStyle(textStyle, textField.style, "TextStyle", textField.styleName, resources) as AD.TextStyle.TextStyle;
485
426
  switch (textField.fieldType) {
486
427
  case "Date":
487
428
  return renderText(style, new Date(Date.now()).toDateString());
@@ -494,18 +435,14 @@ function renderTextField(
494
435
  }
495
436
  }
496
437
 
497
- function renderTextRun(
498
- resources: AD.Resources.Resources,
499
- textStyle: AD.TextStyle.TextStyle,
500
- textRun: AD.TextRun.TextRun
501
- ): TextRun {
438
+ function renderTextRun(resources: AD.Resources.Resources, textStyle: AD.TextStyle.TextStyle, textRun: AD.TextRun.TextRun): TextRun {
502
439
  const style = AD.Resources.getNestedStyle(
503
440
  textStyle,
504
441
  textRun.style,
505
442
  "TextStyle",
506
443
  textRun.styleName,
507
444
  resources,
508
- textRun.nestedStyleNames || []
445
+ textRun.nestedStyleNames ?? []
509
446
  ) as AD.TextStyle.TextStyle;
510
447
 
511
448
  return renderText(style, textRun.text);
@@ -514,10 +451,10 @@ function renderTextRun(
514
451
  function renderPageNumber(style: AD.TextStyle.TextStyle): TextRun {
515
452
  const fontSize = AD.TextStyle.calculateFontSize(style, 10) * abstractDocToDocxFontRatio;
516
453
  return new TextRun({
517
- font: style.fontFamily || "Helvetica",
454
+ font: style.fontFamily ?? "Helvetica",
518
455
  size: fontSize,
519
- color: style.color || "#000000",
520
- bold: style.bold || style.fontWeight === "bold",
456
+ color: style.color ?? "#000000",
457
+ bold: style.bold ?? style.fontWeight === "bold",
521
458
  characterSpacing: style.characterSpacing,
522
459
  underline: style.underline
523
460
  ? {
@@ -532,10 +469,10 @@ function renderPageNumber(style: AD.TextStyle.TextStyle): TextRun {
532
469
  function renderTotalPages(style: AD.TextStyle.TextStyle): TextRun {
533
470
  const fontSize = AD.TextStyle.calculateFontSize(style, 10) * abstractDocToDocxFontRatio;
534
471
  return new TextRun({
535
- font: style.fontFamily || "Helvetica",
472
+ font: style.fontFamily ?? "Helvetica",
536
473
  size: fontSize,
537
- color: style.color || "#000000",
538
- bold: style.bold || style.fontWeight === "bold",
474
+ color: style.color ?? "#000000",
475
+ bold: style.bold ?? style.fontWeight === "bold",
539
476
  characterSpacing: style.characterSpacing,
540
477
  underline: style.underline
541
478
  ? {
@@ -552,10 +489,10 @@ function renderText(style: AD.TextStyle.TextStyle, text: string): TextRun {
552
489
 
553
490
  return new TextRun({
554
491
  text: text,
555
- font: style.fontFamily || "Helvetica",
492
+ font: style.fontFamily ?? "Helvetica",
556
493
  size: fontSize,
557
- color: style.color || "#000000",
558
- bold: style.bold || style.fontWeight === "bold",
494
+ color: style.color ?? "#000000",
495
+ bold: style.bold ?? style.fontWeight === "bold",
559
496
  characterSpacing: style.characterSpacing,
560
497
  underline: style.underline
561
498
  ? {
@@ -566,15 +503,11 @@ function renderText(style: AD.TextStyle.TextStyle, text: string): TextRun {
566
503
  });
567
504
  }
568
505
 
569
- function renderGroup(
570
- group: AD.Group.Group,
571
- resources: AD.Resources.Resources,
572
- availabelWidth: number
573
- ): Array<Paragraph | Table> {
574
- let sofar = Array<Paragraph | Table>();
506
+ function renderGroup(group: AD.Group.Group, resources: AD.Resources.Resources, availabelWidth: number): Array<Paragraph | Table> {
507
+ const sofar = Array<Paragraph | Table>();
575
508
  let keepNext = true;
576
509
  for (let index = 0; index < group.children.length; index++) {
577
- if (index == group.children.length - 1) {
510
+ if (index === group.children.length - 1) {
578
511
  keepNext = false;
579
512
  }
580
513
  sofar.push(...renderSectionElement(group.children[index], resources, availabelWidth, keepNext));
@@ -582,11 +515,7 @@ function renderGroup(
582
515
  return sofar;
583
516
  }
584
517
 
585
- function renderParagraph(
586
- paragraph: AD.Paragraph.Paragraph,
587
- resources: AD.Resources.Resources,
588
- keepNext: boolean
589
- ): Paragraph {
518
+ function renderParagraph(paragraph: AD.Paragraph.Paragraph, resources: AD.Resources.Resources, keepNext: boolean): Paragraph {
590
519
  const style = AD.Resources.getStyle(
591
520
  undefined,
592
521
  paragraph.style,
@@ -600,11 +529,7 @@ function renderParagraph(
600
529
  keepNext: keepNext,
601
530
  alignment:
602
531
  (style.alignment &&
603
- (style.alignment === "Center"
604
- ? AlignmentType.CENTER
605
- : style.alignment === "End"
606
- ? AlignmentType.END
607
- : AlignmentType.START)) ||
532
+ (style.alignment === "Center" ? AlignmentType.CENTER : style.alignment === "End" ? AlignmentType.END : AlignmentType.START)) ??
608
533
  undefined,
609
534
 
610
535
  spacing: {
@@ -3,10 +3,7 @@ import type { Font } from "../../abstract-document/primitives/font.js";
3
3
  import type { TextFontWeight } from "../../abstract-document/styles/text-style.js";
4
4
  import { getResources } from "../shared/get_resources.js";
5
5
 
6
- export function registerFonts(
7
- registerFont: (fontName: string, fontSource: AD.Font.FontSource) => void,
8
- document: AD.AbstractDoc.AbstractDoc
9
- ): void {
6
+ export function registerFonts(registerFont: (fontName: string, fontSource: AD.Font.FontSource) => void, document: AD.AbstractDoc.AbstractDoc): void {
10
7
  const resources = getResources(document);
11
8
  for (const [fontName, font] of Object.entries(resources.fonts ?? {})) {
12
9
  // Required
@@ -17,22 +14,22 @@ export function registerFonts(
17
14
  registerFont(fontName + "-BoldOblique", font.boldItalic);
18
15
  registerFont(fontName + "-BoldItalic", font.boldItalic);
19
16
  // Optional
20
- registerFont(fontName + "-Light", font.light || font.normal);
21
- registerFont(fontName + "-Medium", font.medium || font.normal);
22
- registerFont(fontName + "-ExtraBold", font.extraBold || font.bold);
23
- registerFont(fontName + "-LightOblique", font.lightItalic || font.normal);
24
- registerFont(fontName + "-LightItalic", font.lightItalic || font.normal);
25
- registerFont(fontName + "-MediumOblique", font.mediumItalic || font.italic);
26
- registerFont(fontName + "-MediumItalic", font.mediumItalic || font.italic);
27
- registerFont(fontName + "-ExtraBoldItalic", font.extraBoldItalic || font.boldItalic);
28
- registerFont(fontName + "-ExtraBoldOblique", font.extraBoldItalic || font.boldItalic);
17
+ registerFont(fontName + "-Light", font.light ?? font.normal);
18
+ registerFont(fontName + "-Medium", font.medium ?? font.normal);
19
+ registerFont(fontName + "-ExtraBold", font.extraBold ?? font.bold);
20
+ registerFont(fontName + "-LightOblique", font.lightItalic ?? font.normal);
21
+ registerFont(fontName + "-LightItalic", font.lightItalic ?? font.normal);
22
+ registerFont(fontName + "-MediumOblique", font.mediumItalic ?? font.italic);
23
+ registerFont(fontName + "-MediumItalic", font.mediumItalic ?? font.italic);
24
+ registerFont(fontName + "-ExtraBoldItalic", font.extraBoldItalic ?? font.boldItalic);
25
+ registerFont(fontName + "-ExtraBoldOblique", font.extraBoldItalic ?? font.boldItalic);
29
26
  }
30
27
  }
31
28
 
32
29
  function getFontWeightFromStyle(textStyle: AD.TextStyle.TextStyle): TextFontWeight {
33
- return textStyle.fontWeight
34
- ? textStyle.fontWeight
35
- : textStyle.light
30
+ return (
31
+ textStyle.fontWeight ??
32
+ (textStyle.light
36
33
  ? "light"
37
34
  : textStyle.normal
38
35
  ? "normal"
@@ -42,7 +39,8 @@ function getFontWeightFromStyle(textStyle: AD.TextStyle.TextStyle): TextFontWeig
42
39
  ? "mediumBold"
43
40
  : textStyle.extraBold
44
41
  ? "extraBold"
45
- : "normal";
42
+ : "normal")
43
+ );
46
44
  }
47
45
 
48
46
  function getFontWeightFromAttributes(attribs: Record<string, string>): TextFontWeight {
@@ -66,12 +64,8 @@ export function getFontStyleName(attributes: Record<string, string>): keyof Font
66
64
  return `${fontWeight === "mediumBold" ? "medium" : fontWeight}${italic ? "Italic" : ""}`;
67
65
  }
68
66
 
69
- export function getFontName(
70
- fontFamily: string | undefined,
71
- fontWeight: TextFontWeight,
72
- italic: boolean | undefined
73
- ): string {
74
- const name = fontFamily || "Helvetica";
67
+ export function getFontName(fontFamily: string | undefined, fontWeight: TextFontWeight, italic: boolean | undefined): string {
68
+ const name = fontFamily ?? "Helvetica";
75
69
  if (fontWeight === "light" && italic) {
76
70
  return name + "-LightOblique";
77
71
  } else if (fontWeight === "bold" && italic) {
@@ -0,0 +1,43 @@
1
+ import * as AD from "../../abstract-document/index.js";
2
+
3
+ export function getHeaderAndFooter(
4
+ section: AD.Section.Section,
5
+ pageNo: number
6
+ ): {
7
+ readonly header: Array<AD.SectionElement.SectionElement>;
8
+ readonly footer: Array<AD.SectionElement.SectionElement>;
9
+ readonly headerMargins: Required<AD.LayoutFoundation.LayoutFoundation>;
10
+ readonly footerMargins: Required<AD.LayoutFoundation.LayoutFoundation>;
11
+ } {
12
+ const FIRST_PAGE = 1;
13
+ const EVEN_PAGE = 0;
14
+ const ODD_PAGE = 1;
15
+ switch (true) {
16
+ //first page
17
+ case pageNo === FIRST_PAGE: {
18
+ const normalHeader = section.page.frontHeader === undefined || section.page.frontHeader.length === 0;
19
+ const normalFooter = section.page.frontFooter === undefined || section.page.frontFooter.length === 0;
20
+ return {
21
+ footer: normalFooter ? section.page.footer : section.page.frontFooter,
22
+ header: normalHeader ? section.page.header : section.page.frontHeader,
23
+ headerMargins: AD.LayoutFoundation.orDefault(
24
+ normalHeader ? section.page.style.headerMargins : (section.page.style.firstPageHeaderMargins ?? section.page.style.headerMargins)
25
+ ),
26
+ footerMargins: AD.LayoutFoundation.orDefault(
27
+ normalFooter ? section.page.style.footerMargins : (section.page.style.firstPageFooterMargins ?? section.page.style.footerMargins)
28
+ ),
29
+ };
30
+ }
31
+ case pageNo === 0:
32
+ case pageNo % 2 === EVEN_PAGE:
33
+ case pageNo % 2 === ODD_PAGE:
34
+ default: {
35
+ return {
36
+ header: section.page.header,
37
+ footer: section.page.footer,
38
+ headerMargins: AD.LayoutFoundation.orDefault(section.page.style.headerMargins),
39
+ footerMargins: AD.LayoutFoundation.orDefault(section.page.style.footerMargins),
40
+ };
41
+ }
42
+ }
43
+ }