Skip to main content

DocumentRenderV3Command

DocumentRenderV3Command renders a stored DOCX template using the V2-compatible template syntax. When PDF output is requested, it uses the warm, supervised LibreOffice V3 conversion service to avoid starting a new LibreOffice process for every document.

Request​

var result = doCmd('DocumentRenderV3Command', {
Data: {
documentName: 'loan-offer-template',
context: JSON.stringify({
customerName: 'Ada Okafor',
requestNumber: 'WFR-LOAN-20261115-001',
approvedAmount: 2500000,
currency: 'NGN'
}),
isPdfOutput: true
}
});
PropertyTypeRequiredDescription
Data.documentNamestringYesTemplate name or unique identifier in DocumentTemplateDefinitiion.
Data.contextstringYesStringified JSON containing values used by template placeholders.
Data.isPdfOutputbooleanNoWhen true, requests PDF conversion; otherwise returns DOCX.

Successful response​

{
"isSuccessful": true,
"statusCode": null,
"message": "Document 'loan-offer-template' rendered and converted to PDF successfully (LibreOffice V3).",
"mimeType": "application/pdf",
"data": "JVBERi0xLjcK..."
}

data is Base64. Decode it according to mimeType.

PDF fallback​

If template rendering succeeds but LibreOffice conversion fails, the command returns the rendered DOCX instead of discarding the document:

{
"isSuccessful": true,
"message": "Document 'loan-offer-template' rendered successfully (LibreOffice V3 PDF conversion failed: ...; DOCX returned).",
"mimeType": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"data": "UEsDBBQAAAAI..."
}

The caller must always use the returned mimeType, rather than assuming PDF because isPdfOutput was requested.

Operational behavior​

  • Uses the stored DOCX template content; it does not accept a Base64 template input.
  • Renders body, headers, footers, tables, conditions, loops, and formatting through the shared V2 rendering functions.
  • Uses the V3 warm LibreOffice conversion service for PDF.
  • Applies the configured PDF timeout.
  • Produces stage timing and diagnostic logs using the document-rendering log configuration.
  • Cancellation is propagated rather than converted into a normal failure response.

For template syntax, see DocumentRenderV2Command and the DocumentRender V2 Template Guide.