@nestjsforge/pdfme

Working with Plugins

Extend PDF generation with custom pdfme schema plugins.

pdfme has a plugin system for custom schema types. Register plugins globally to use them in your templates.

Using @pdfme/schemas plugins

import { barcodes, image, text } from '@pdfme/schemas';

PdfmeModule.forRoot({
  plugins: {
    text,
    image,
    qrcode: barcodes.qrcode,
    ean13: barcodes.ean13,
  },
})

Custom plugin

import { Plugin, Schema } from '@pdfme/common';

interface WatermarkSchema extends Schema {
  type: 'watermark';
  text: string;
  opacity: number;
}

const watermarkPlugin: Plugin<WatermarkSchema> = {
  pdf: async (arg) => {
    const { schema, pdfDoc, page } = arg;
    // Draw watermark on the page...
  },
  ui: async () => {},
  propPanel: { schema: {}, defaultSchema: { type: 'watermark', text: '', opacity: 0.3 } },
};

PdfmeModule.forRoot({
  plugins: { watermark: watermarkPlugin },
})