@pdfme/generator 5.1.6-dev.2 → 5.1.7-dev.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfme/generator",
3
- "version": "5.1.6-dev.2",
3
+ "version": "5.1.7-dev.2",
4
4
  "sideEffects": false,
5
5
  "author": "hand-dot",
6
6
  "license": "MIT",
package/src/generate.ts CHANGED
@@ -1,6 +1,11 @@
1
1
  import * as pdfLib from '@pdfme/pdf-lib';
2
2
  import type { GenerateProps } from '@pdfme/common';
3
- import { checkGenerateProps, getDynamicTemplate } from '@pdfme/common';
3
+ import {
4
+ checkGenerateProps,
5
+ getDynamicTemplate,
6
+ isBlankPdf,
7
+ replacePlaceholders,
8
+ } from '@pdfme/common';
4
9
  import { getDynamicHeightsForTable } from '@pdfme/schemas/utils';
5
10
  import {
6
11
  insertPage,
@@ -56,6 +61,33 @@ const generate = async (props: GenerateProps) => {
56
61
  const basePage = basePages[j];
57
62
  const embedPdfBox = embedPdfBoxes[j];
58
63
  const page = insertPage({ basePage, embedPdfBox, pdfDoc });
64
+
65
+ if (isBlankPdf(basePdf) && basePdf.staticSchema) {
66
+ for (let k = 0; k < basePdf.staticSchema.length; k += 1) {
67
+ const staticSchema = basePdf.staticSchema[k];
68
+ const render = renderObj[staticSchema.type];
69
+ if (!render) {
70
+ continue;
71
+ }
72
+ const value = replacePlaceholders({
73
+ content: staticSchema.content || '',
74
+ variables: { ...input, totalPages: basePages.length, currentPage: j + 1 },
75
+ schemas: dynamicTemplate.schemas,
76
+ });
77
+
78
+ await render({
79
+ value,
80
+ schema: staticSchema,
81
+ basePdf,
82
+ pdfLib,
83
+ pdfDoc,
84
+ page,
85
+ options,
86
+ _cache,
87
+ });
88
+ }
89
+ }
90
+
59
91
  for (let l = 0; l < schemaNames.length; l += 1) {
60
92
  const name = schemaNames[l];
61
93
  const schemaPage = dynamicTemplate.schemas[j] || [];
@@ -68,7 +100,14 @@ const generate = async (props: GenerateProps) => {
68
100
  if (!render) {
69
101
  continue;
70
102
  }
71
- const value = schema.readOnly ? schema.content || '' : input[name];
103
+ const value = schema.readOnly
104
+ ? replacePlaceholders({
105
+ content: schema.content || '',
106
+ variables: { ...input, totalPages: basePages.length, currentPage: j + 1 },
107
+ schemas: dynamicTemplate.schemas,
108
+ })
109
+ : input[name] || '';
110
+
72
111
  await render({ value, schema, basePdf, pdfLib, pdfDoc, page, options, _cache });
73
112
  }
74
113
  }