pols-pdf 1.2.0 → 1.2.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.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +10 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -31,6 +31,7 @@ class PPdf {
|
|
|
31
31
|
configPage;
|
|
32
32
|
engine;
|
|
33
33
|
template;
|
|
34
|
+
templateIsRunning = false;
|
|
34
35
|
currentFont = {
|
|
35
36
|
name: 'Helvetica',
|
|
36
37
|
bold: false,
|
|
@@ -107,6 +108,8 @@ class PPdf {
|
|
|
107
108
|
this.addPage();
|
|
108
109
|
}
|
|
109
110
|
addPage(config) {
|
|
111
|
+
if (this.templateIsRunning)
|
|
112
|
+
throw new Error(`Intento de inserción de página dentro de una llamada a la función 'template'`);
|
|
110
113
|
const finalConfig = {
|
|
111
114
|
...this.configPage,
|
|
112
115
|
...(config ?? {}),
|
|
@@ -116,7 +119,13 @@ class PPdf {
|
|
|
116
119
|
this.configPage = finalConfig;
|
|
117
120
|
this.cursor.top = finalConfig.margins.top;
|
|
118
121
|
this.drawMarginLines();
|
|
119
|
-
this.
|
|
122
|
+
this.templateIsRunning = true;
|
|
123
|
+
try {
|
|
124
|
+
this.template?.();
|
|
125
|
+
}
|
|
126
|
+
finally {
|
|
127
|
+
this.templateIsRunning = false;
|
|
128
|
+
}
|
|
120
129
|
}
|
|
121
130
|
/* Dibuja líneas grises en los márgenes de la hoja actual, sin alterar el cursor */
|
|
122
131
|
drawMarginLines() {
|