@pdfme/schemas
Version:
TypeScript base PDF generator and React base UI. Open source, developed by the community, and completely free to use under the MIT license!
22 lines (17 loc) • 634 B
text/typescript
import { PDFRenderProps } from '@pdfme/common';
import { MultiVariableTextSchema } from './types.js';
import { pdfRender as parentPdfRender } from '../text/pdfRender.js';
import { substituteVariables, validateVariables } from './helper.js';
export const pdfRender = async (arg: PDFRenderProps<MultiVariableTextSchema>) => {
const { value, schema, ...rest } = arg;
if (!validateVariables(value, schema)) {
// Don't render if a required variable is missing
return;
}
const renderArgs = {
value: substituteVariables(schema.text || '', value),
schema,
...rest,
};
await parentPdfRender(renderArgs);
};