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
Parameter | Type | Description |
---|---|---|
docDefinition | TDocumentDefinitions | The PDF document definition. |
filename | string | (Optional) Optional filename for the PDF binary resource. |
tableLayouts | Record<string, CustomTableLayout> | (Optional) Optional pdfmake custom table layout. |
fonts | TFontDictionary | (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/