Action that generates PDF files from HTML or Markdown content Supports various formatting options and can save to MJ Storage

Example

// Generate PDF from Markdown
await runAction({
ActionName: 'PDF Generator',
Params: [{
Name: 'Content',
Value: '# Report Title\n\nThis is the report content...'
}, {
Name: 'ContentType',
Value: 'markdown'
}]
});

// Generate PDF from HTML with custom options
await runAction({
ActionName: 'PDF Generator',
Params: [{
Name: 'Content',
Value: '<h1>Report</h1><p>Content here...</p>'
}, {
Name: 'Options',
Value: {
margin: { top: 50, bottom: 50, left: 72, right: 72 },
fontSize: 12,
font: 'Helvetica'
}
}]
});

Hierarchy

  • BaseFileHandlerAction
    • PDFGeneratorAction

Constructors

Methods

  • Generates a PDF from HTML or Markdown content

    Parameters

    • params: RunActionParams<any>

      The action parameters containing:

      • Content: HTML or Markdown string to convert to PDF
      • ContentType: "html" | "markdown" (default: "html")
      • Options: PDF generation options object containing:
        • margin: { top, bottom, left, right } in points (default: 72)
        • fontSize: Base font size (default: 12)
        • font: Font family (default: 'Helvetica')
        • orientation: 'portrait' | 'landscape' (default: 'portrait')
        • size: Paper size like 'A4', 'Letter', etc. (default: 'Letter')
      • OutputFileID: Optional MJ Storage file ID to save to
      • FileName: Name for the generated PDF (default: 'document.pdf')

    Returns Promise<ActionResultSimple>

    Base64 encoded PDF data or FileID if saved to storage

  • Executes the action with the provided parameters.

    Parameters

    • params: RunActionParams<any>

      The action execution parameters including context

    Returns Promise<ActionResultSimple>

    Promise resolving to the action result

  • Get file content from various sources based on parameters Priority: FileID > FileURL > Data parameter

    Parameters

    • params: RunActionParams<any>

      Action parameters

    • dataParamName: string

      Name of the parameter containing direct data

    • fileParamName: string = 'FileID'

      Name of the parameter containing file ID (default: 'FileID')

    • urlParamName: string = 'FileURL'

      Name of the parameter containing file URL (default: 'FileURL')

    Returns Promise<{
        content: string | Buffer;
        fileName?: string;
        mimeType?: string;
        source: "url" | "storage" | "direct";
    }>

    Object with content and metadata