Skip to main content

PdfMakeWrapper

this class is used when working on client side, this class extends from DocumentDefinition class.

create(): ICreatePDF

Creates the pdf document. This returns other methods (ICreatePDF) that you can use depending on what you want to do with the document.

import { PdfMakeWrapper } from 'pdfmake-wrapper';

const pdf = new PdfMakeWrapper();

pdf.create();

/**
* Returns:
* download(filename?: string, cb?: (v?: any) => void, options?: any ): void;
* open(options?: any, win?: Window ): void;
* print(options?: any, win?: Window ): void;
* getDataUrl(cb?: (v?: any) => void, options?: any ): void;
* getBase64(cb?: (v?: any) => void, options?: any ): void;
* getBuffer(cb?: (v?: any) => void, options?: any ): void;
* getBlob(cb?: (v?: any) => void, options?: any ): void;
*/

static setFonts(fonts: IFonts, fontTypesConfig?: Record<string, IFontTypes>): void

Sets the fonts to use. you can set either pdfmake default fonts or your custom fonts. More about working with fonts here.

import { PdfMakeWrapper } from 'pdfmake-wrapper';
import pdfFonts from "pdfmake/build/vfs_fonts"; // pdfmake default fonts

/**
* Configuring the default fonts provided by pdfmake. These are the fonts that pdfmake or pdfmake-wrapper
* have available to use.
*/

PdfMakeWrapper.setFonts(pdfFonts);

ln(lines: number = 1): string

DEPRECATION

This method will be deprecated in next releases. Avoid to use it, instead, use '\n'.

Adds new lines. By default '\n'.

import { PdfMakeWrapper } from 'pdfmake-wrapper';

const pdf = new PdfMakeWrapper();

pdf.add(
pdf.ln(2)
);

/**
* Internally:
* {
* content: [
* '\n\n'
* ]
* }
*/

Types

ICreatePDF

Defines the result of a create method.

  • download(filename?: string, cb?: (v?: any) => void, options?: any ): void;
  • open(options?: any, win?: Window ): void;
  • print(options?: any, win?: Window ): void;
  • getDataUrl(cb?: (v?: any) => void, options?: any ): void;
  • getBase64(cb?: (v?: any) => void, options?: any ): void;
  • getBuffer(cb?: (v?: any) => void, options?: any ): void;
  • getBlob(cb?: (v?: any) => void, options?: any ): void;

IFonts

Defines the format of the generated fonts. This is used internally.

  • pdfMake: IVFS;

IFontTypes

Defines the font types.

  • normal: string;
  • bold: string;
  • italics: string;
  • bolditalics: string;