Skip to main content

core.medplumclient.createpdf

Home > @medplum/core > MedplumClient > createPdf

MedplumClient.createPdf() method

Creates a PDF as a FHIR Binary resource based on pdfmake document definition.

The return value is the newly created resource, including the ID and meta.

The docDefinition parameter is a pdfmake document definition.

Signature:

createPdf(docDefinition: TDocumentDefinitions, filename?: string, tableLayouts?: Record<string, CustomTableLayout>, fonts?: TFontDictionary): Promise<Binary>;

Parameters

ParameterTypeDescription
docDefinitionTDocumentDefinitionsThe PDF document definition.
filenamestring(Optional) Optional filename for the PDF binary resource.
tableLayoutsRecord<string, CustomTableLayout>(Optional) Optional pdfmake custom table layout.
fontsTFontDictionary(Optional) Optional pdfmake custom font dictionary.

Returns:

Promise<Binary>

The result of the create operation.

Example

Example:

const result = await medplum.createPdf({
content: ['Hello world']
});
console.log(result.id);

See the pdfmake document definition for full details: https://pdfmake.github.io/docs/0.1/document-definition-object/