Skip to content

Saving a PDF (bizzStream.savePdf)

You can use bizzStream.savePdf to generate a PDF from a template and save it to a document attachment field.

Syntax

bizzStream.savePdf(options);

Parameters

The savePdf function takes an options object with the following properties:

Parameter Type Required Description
templateId String Yes The ID of the template used to generate the PDF.
saveTo String Yes The ID of the header attachment field where the PDF is saved.
renderLanguage String Yes Accepts currentUser, en, or nl.
operation String Yes Use add to keep existing attachments and add the PDF, or overwrite to replace existing attachments.
documentId String No The ID of the saved document used to render and store the PDF. When omitted or null, the current server document is used.

Return value

The function returns metadata for the uploaded PDF attachment.

Examples

Save a PDF to a specific document

const attachment = bizzStream.savePdf({
  templateId: 'invoiceTemplateId',
  saveTo: 'invoiceAttachmentFieldId',
  renderLanguage: 'currentUser',
  operation: 'add',
  documentId: 'invoiceDocumentId',
});

Use the current server document

const attachment = bizzStream.savePdf({
  templateId: 'invoiceTemplateId',
  saveTo: 'invoiceAttachmentFieldId',
  renderLanguage: 'currentUser',
  operation: 'overwrite',
});

The current server document must already be saved. The function reloads the document from the database before generating the PDF. It returns an error when the document does not exist or no current server document is available.