@pdfme/common 6.1.1-dev.8 → 6.1.2-dev.11

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/dist/index.d.ts CHANGED
@@ -1,12 +1,13 @@
1
1
  import { PDFME_VERSION } from './version.js';
2
2
  import { MM_TO_PT_RATIO, PT_TO_MM_RATIO, PT_TO_PX_RATIO, BLANK_PDF, BLANK_A4_PDF, CUSTOM_A4_PDF, ZOOM, DEFAULT_FONT_NAME } from './constants.js';
3
- import type { ChangeSchemaItem, ChangeSchemas, SchemaPageArray, PropPanel, PropPanelSchema, PropPanelWidgetProps, PDFRenderProps, Mode, UIRenderProps, Plugin, Lang, Dict, Size, Schema, SchemaForUI, Font, ColorType, BasePdf, BlankPdf, CustomPdf, Template, CommonOptions, GeneratorOptions, Plugins, PluginRegistry, GenerateProps, UIOptions, UIProps, PreviewProps, DesignerProps, DynamicLayoutArgs, DynamicLayoutCallbackResult, DynamicLayoutPatchArgs, DynamicLayoutResult, GetDynamicLayout } from './types.js';
3
+ import type { ChangeSchemaItem, ChangeSchemas, SchemaPageArray, PropPanel, PropPanelSchema, PropPanelWidgetProps, PDFRenderProps, Mode, UIRenderProps, Plugin, Lang, Dict, Size, Schema, SchemaForUI, Font, ColorType, DynamicLayoutRange, DynamicLayoutSplitRange, BasePdf, BlankPdf, CustomPdf, Template, CommonOptions, GeneratorOptions, Plugins, PluginRegistry, GenerateProps, UIOptions, UIProps, PreviewProps, DesignerProps, DynamicLayoutArgs, DynamicLayoutCallbackResult, DynamicLayoutPatchArgs, DynamicLayoutResult, GetDynamicLayout } from './types.js';
4
4
  import type { PdfLinkAnnotationRect } from './helper.js';
5
5
  import type { PageOrientation, PageSize, PageSizePreset } from './pageSize.js';
6
6
  import { cloneDeep, getFallbackFontName, getDefaultFont, getB64BasePdf, b64toUint8Array, checkFont, checkInputs, checkUIOptions, checkTemplate, checkUIProps, checkPreviewProps, checkDesignerProps, checkGenerateProps, mm2pt, pt2mm, pt2px, px2mm, isHexValid, getInputFromTemplate, isBlankPdf, isUrlSafeToFetch, getInternalLinkTarget, normalizeInternalLinkHref, normalizeLinkHref, normalizeSafeLinkUri, registerInternalLinkAnchor, registerInternalLinkAnnotation, resetInternalLinkAnnotations, applyInternalLinkAnnotations } from './helper.js';
7
7
  import { PAGE_SIZE_PRESETS, detectPaperSize, resolvePageSize } from './pageSize.js';
8
8
  import { getDynamicTemplate } from './dynamicTemplate.js';
9
+ import { createDynamicLayoutSplitRange, getDynamicLayoutSplitRange } from './splitRange.js';
9
10
  import { replacePlaceholders } from './expression.js';
10
11
  import { pluginRegistry } from './pluginRegistry.js';
11
- export { PDFME_VERSION, MM_TO_PT_RATIO, PT_TO_MM_RATIO, PT_TO_PX_RATIO, BLANK_PDF, BLANK_A4_PDF, CUSTOM_A4_PDF, ZOOM, DEFAULT_FONT_NAME, cloneDeep, getFallbackFontName, getDefaultFont, getB64BasePdf, b64toUint8Array, mm2pt, pt2mm, pt2px, px2mm, isHexValid, getInputFromTemplate, isBlankPdf, getDynamicTemplate, replacePlaceholders, checkFont, checkInputs, checkUIOptions, checkTemplate, checkUIProps, checkPreviewProps, checkDesignerProps, checkGenerateProps, pluginRegistry, isUrlSafeToFetch, getInternalLinkTarget, normalizeInternalLinkHref, normalizeLinkHref, normalizeSafeLinkUri, registerInternalLinkAnchor, registerInternalLinkAnnotation, resetInternalLinkAnnotations, applyInternalLinkAnnotations, PAGE_SIZE_PRESETS, detectPaperSize, resolvePageSize, };
12
- export type { Lang, Dict, Size, Schema, SchemaForUI, Font, ColorType, BasePdf, BlankPdf, CustomPdf, Template, CommonOptions, GeneratorOptions, Plugin, Plugins, PluginRegistry, GenerateProps, UIOptions, UIProps, PreviewProps, DesignerProps, ChangeSchemaItem, ChangeSchemas, SchemaPageArray, PropPanel, PropPanelSchema, PropPanelWidgetProps, PDFRenderProps, UIRenderProps, Mode, DynamicLayoutArgs, DynamicLayoutCallbackResult, DynamicLayoutPatchArgs, DynamicLayoutResult, GetDynamicLayout, PdfLinkAnnotationRect, PageOrientation, PageSize, PageSizePreset, };
12
+ export { PDFME_VERSION, MM_TO_PT_RATIO, PT_TO_MM_RATIO, PT_TO_PX_RATIO, BLANK_PDF, BLANK_A4_PDF, CUSTOM_A4_PDF, ZOOM, DEFAULT_FONT_NAME, cloneDeep, getFallbackFontName, getDefaultFont, getB64BasePdf, b64toUint8Array, mm2pt, pt2mm, pt2px, px2mm, isHexValid, getInputFromTemplate, isBlankPdf, getDynamicTemplate, replacePlaceholders, checkFont, checkInputs, checkUIOptions, checkTemplate, checkUIProps, checkPreviewProps, checkDesignerProps, checkGenerateProps, pluginRegistry, isUrlSafeToFetch, getInternalLinkTarget, normalizeInternalLinkHref, normalizeLinkHref, normalizeSafeLinkUri, registerInternalLinkAnchor, registerInternalLinkAnnotation, resetInternalLinkAnnotations, applyInternalLinkAnnotations, PAGE_SIZE_PRESETS, detectPaperSize, resolvePageSize, createDynamicLayoutSplitRange, getDynamicLayoutSplitRange, };
13
+ export type { Lang, Dict, Size, Schema, SchemaForUI, Font, ColorType, DynamicLayoutRange, DynamicLayoutSplitRange, BasePdf, BlankPdf, CustomPdf, Template, CommonOptions, GeneratorOptions, Plugin, Plugins, PluginRegistry, GenerateProps, UIOptions, UIProps, PreviewProps, DesignerProps, ChangeSchemaItem, ChangeSchemas, SchemaPageArray, PropPanel, PropPanelSchema, PropPanelWidgetProps, PDFRenderProps, UIRenderProps, Mode, DynamicLayoutArgs, DynamicLayoutCallbackResult, DynamicLayoutPatchArgs, DynamicLayoutResult, GetDynamicLayout, PdfLinkAnnotationRect, PageOrientation, PageSize, PageSizePreset, };
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { Buffer } from "buffer";
3
3
  import { PDFName } from "@pdfme/pdf-lib";
4
4
  import * as acorn from "acorn";
5
5
  //#region src/version.ts
6
- var PDFME_VERSION = "6.1.1";
6
+ var PDFME_VERSION = "6.1.2";
7
7
  //#endregion
8
8
  //#region src/pageSize.ts
9
9
  var PAGE_SIZE_PRESETS = {
@@ -223,6 +223,11 @@ z.object({
223
223
  height: z.number(),
224
224
  width: z.number()
225
225
  });
226
+ var DynamicLayoutSplitRange = z.object({
227
+ unit: z.string().min(1),
228
+ start: z.number(),
229
+ end: z.number().optional()
230
+ });
226
231
  var Schema = z.object({
227
232
  name: z.string(),
228
233
  type: z.string(),
@@ -237,18 +242,7 @@ var Schema = z.object({
237
242
  opacity: z.number().optional(),
238
243
  readOnly: z.boolean().optional(),
239
244
  required: z.boolean().optional(),
240
- __bodyRange: z.object({
241
- start: z.number(),
242
- end: z.number().optional()
243
- }).optional(),
244
- __itemRange: z.object({
245
- start: z.number(),
246
- end: z.number().optional()
247
- }).optional(),
248
- __textLineRange: z.object({
249
- start: z.number(),
250
- end: z.number().optional()
251
- }).optional(),
245
+ __splitRange: DynamicLayoutSplitRange.optional(),
252
246
  __isSplit: z.boolean().optional()
253
247
  }).passthrough();
254
248
  var SchemaForUIAdditionalInfo = z.object({ id: z.string() });
@@ -1124,6 +1118,10 @@ var getDynamicTemplate = async (arg) => {
1124
1118
  const PARALLEL_LIMIT = 10;
1125
1119
  for (let pageIndex = 0; pageIndex < template.schemas.length; pageIndex++) {
1126
1120
  const pageSchemas = template.schemas[pageIndex];
1121
+ if (pageSchemas.length === 0) {
1122
+ resultPages.push([]);
1123
+ continue;
1124
+ }
1127
1125
  const { items, orderMap } = normalizePageSchemas(pageSchemas, paddingTop);
1128
1126
  for (let i = 0; i < items.length; i += PARALLEL_LIMIT) {
1129
1127
  const chunk = items.slice(i, i + PARALLEL_LIMIT);
@@ -1140,7 +1138,6 @@ var getDynamicTemplate = async (arg) => {
1140
1138
  const processedPages = processDynamicPage(items, orderMap, contentHeight, paddingTop);
1141
1139
  resultPages.push(...processedPages);
1142
1140
  }
1143
- removeTrailingEmptyPages(resultPages);
1144
1141
  if (resultPages.length === template.schemas.length) {
1145
1142
  let unchanged = true;
1146
1143
  for (let i = 0; i < resultPages.length && unchanged; i++) {
@@ -1162,6 +1159,21 @@ var getDynamicTemplate = async (arg) => {
1162
1159
  };
1163
1160
  };
1164
1161
  //#endregion
1162
+ //#region src/splitRange.ts
1163
+ var createDynamicLayoutSplitRange = (unit, start, end) => ({
1164
+ unit,
1165
+ start,
1166
+ ...end === void 0 ? {} : { end }
1167
+ });
1168
+ var getDynamicLayoutSplitRange = (schema, unit) => {
1169
+ const range = schema.__splitRange;
1170
+ if (range?.unit !== unit) return void 0;
1171
+ return {
1172
+ start: range.start,
1173
+ ...range.end === void 0 ? {} : { end: range.end }
1174
+ };
1175
+ };
1176
+ //#endregion
1165
1177
  //#region src/pluginRegistry.ts
1166
1178
  /**
1167
1179
  * Wraps plugins collection with utility methods
@@ -1188,6 +1200,6 @@ var pluginRegistry = (plugins) => {
1188
1200
  };
1189
1201
  };
1190
1202
  //#endregion
1191
- export { BLANK_A4_PDF, BLANK_PDF, CUSTOM_A4_PDF, DEFAULT_FONT_NAME, MM_TO_PT_RATIO, PAGE_SIZE_PRESETS, PDFME_VERSION, PT_TO_MM_RATIO, PT_TO_PX_RATIO, ZOOM, applyInternalLinkAnnotations, b64toUint8Array, checkDesignerProps, checkFont, checkGenerateProps, checkInputs, checkPreviewProps, checkTemplate, checkUIOptions, checkUIProps, cloneDeep, detectPaperSize, getB64BasePdf, getDefaultFont, getDynamicTemplate, getFallbackFontName, getInputFromTemplate, getInternalLinkTarget, isBlankPdf, isHexValid, isUrlSafeToFetch, mm2pt, normalizeInternalLinkHref, normalizeLinkHref, normalizeSafeLinkUri, pluginRegistry, pt2mm, pt2px, px2mm, registerInternalLinkAnchor, registerInternalLinkAnnotation, replacePlaceholders, resetInternalLinkAnnotations, resolvePageSize };
1203
+ export { BLANK_A4_PDF, BLANK_PDF, CUSTOM_A4_PDF, DEFAULT_FONT_NAME, MM_TO_PT_RATIO, PAGE_SIZE_PRESETS, PDFME_VERSION, PT_TO_MM_RATIO, PT_TO_PX_RATIO, ZOOM, applyInternalLinkAnnotations, b64toUint8Array, checkDesignerProps, checkFont, checkGenerateProps, checkInputs, checkPreviewProps, checkTemplate, checkUIOptions, checkUIProps, cloneDeep, createDynamicLayoutSplitRange, detectPaperSize, getB64BasePdf, getDefaultFont, getDynamicLayoutSplitRange, getDynamicTemplate, getFallbackFontName, getInputFromTemplate, getInternalLinkTarget, isBlankPdf, isHexValid, isUrlSafeToFetch, mm2pt, normalizeInternalLinkHref, normalizeLinkHref, normalizeSafeLinkUri, pluginRegistry, pt2mm, pt2px, px2mm, registerInternalLinkAnchor, registerInternalLinkAnnotation, replacePlaceholders, resetInternalLinkAnnotations, resolvePageSize };
1192
1204
 
1193
1205
  //# sourceMappingURL=index.js.map